Skip to content

Commit aee8a04

Browse files
author
philippe baetens
committed
media/i2c: cleanup mira220 driver.
- For now, only support RGB format. - Remove commented out code. - Remove unused code such as mira220_resume and suspend - change order of CLK and REG perparation - Mira220-> streaming removed.
1 parent 64876f0 commit aee8a04

File tree

1 file changed

+6
-61
lines changed

1 file changed

+6
-61
lines changed

drivers/media/i2c/mira220.c

+6-61
Original file line numberDiff line numberDiff line change
@@ -1003,13 +1003,9 @@ static const char *const mira220_supply_name[] = {
10031003
#define MIRA220_NUM_SUPPLIES ARRAY_SIZE(mira220_supply_name)
10041004

10051005

1006-
// The supported formats. All flip/mirror combinations have the same byte order because the sensor
1007-
// is monochrome
1006+
// Mira220 comes in monochrome and RGB variants. This driver implements the RGB variant.
10081007

10091008
static const u32 codes[] = {
1010-
//MEDIA_BUS_FMT_Y8_1X8,
1011-
//MEDIA_BUS_FMT_Y10_1X10,
1012-
//MEDIA_BUS_FMT_Y12_1X12,
10131009
MEDIA_BUS_FMT_SGRBG8_1X8,
10141010
MEDIA_BUS_FMT_SGRBG10_1X10,
10151011
MEDIA_BUS_FMT_SGRBG12_1X12,
@@ -1051,7 +1047,6 @@ struct mira220 {
10511047
struct clk *xclk; /* system clock to MIRA220 */
10521048
u32 xclk_freq;
10531049

1054-
//struct gpio_desc *reset_gpio;
10551050
struct regulator_bulk_data supplies[MIRA220_NUM_SUPPLIES];
10561051

10571052
struct v4l2_ctrl_handler ctrl_handler;
@@ -1071,11 +1066,6 @@ struct mira220 {
10711066

10721067
struct mutex mutex;
10731068

1074-
/* Streaming on/off */
1075-
bool streaming;
1076-
1077-
/* User specified I2C device address */
1078-
u32 tbd_client_i2c_addr;
10791069
struct regmap *regmap;
10801070
};
10811071

@@ -1096,19 +1086,20 @@ static int mira220_power_on(struct device *dev)
10961086
if (ret) {
10971087
dev_err(&client->dev, "%s: failed to enable regulators\n",
10981088
__func__);
1099-
return ret;
1089+
goto reg_off;
11001090
}
11011091
ret = clk_prepare_enable(mira220->xclk);
11021092
if (ret) {
11031093
dev_err(&client->dev, "%s: failed to enable clock\n", __func__);
1104-
goto reg_off;
1094+
goto clk_off;
11051095
}
1106-
// gpiod_set_value_cansleep(mira220->reset_gpio, 1);
11071096
usleep_range(MIRA220_XCLR_MIN_DELAY_US,
11081097
MIRA220_XCLR_MIN_DELAY_US + MIRA220_XCLR_DELAY_RANGE_US);
11091098

11101099
return 0;
11111100

1101+
clk_off:
1102+
clk_disable_unprepare(mira220->xclk);
11121103
reg_off:
11131104
ret = regulator_bulk_disable(MIRA220_NUM_SUPPLIES, mira220->supplies);
11141105
return ret;
@@ -1121,8 +1112,8 @@ static int mira220_power_off(struct device *dev)
11211112
struct mira220 *mira220 = to_mira220(sd);
11221113
(void)mira220;
11231114

1124-
regulator_bulk_disable(MIRA220_NUM_SUPPLIES, mira220->supplies);
11251115
clk_disable_unprepare(mira220->xclk);
1116+
regulator_bulk_disable(MIRA220_NUM_SUPPLIES, mira220->supplies);
11261117

11271118
return 0;
11281119
}
@@ -1337,7 +1328,6 @@ static int mira220_set_ctrl(struct v4l2_ctrl *ctrl)
13371328

13381329
switch (ctrl->id) {
13391330
case V4L2_CID_ANALOGUE_GAIN:
1340-
// ret = mira220_write_analog_gain_reg(mira220, ctrl->val);
13411331
break;
13421332
case V4L2_CID_EXPOSURE:
13431333
ret = mira220_write_exposure_reg(mira220, ctrl->val);
@@ -1684,7 +1674,6 @@ static int mira220_start_streaming(struct mira220 *mira220)
16841674
reg_list = &mira220->mode->reg_list;
16851675
ret = cci_multi_reg_write(mira220->regmap, reg_list->regs,
16861676
reg_list->num_of_regs, NULL);
1687-
// ret = mira220_write_regs(mira220, reg_list->regs, reg_list->num_of_regs);
16881677
if (ret) {
16891678
dev_err(&client->dev, "%s failed to set mode\n", __func__);
16901679
goto err_rpm_put;
@@ -1742,10 +1731,6 @@ static int mira220_set_stream(struct v4l2_subdev *sd, int enable)
17421731
int ret = 0;
17431732

17441733
mutex_lock(&mira220->mutex);
1745-
if (mira220->streaming == enable) {
1746-
mutex_unlock(&mira220->mutex);
1747-
return 0;
1748-
}
17491734

17501735
if (enable) {
17511736
/*
@@ -1759,8 +1744,6 @@ static int mira220_set_stream(struct v4l2_subdev *sd, int enable)
17591744
mira220_stop_streaming(mira220);
17601745
}
17611746

1762-
mira220->streaming = enable;
1763-
17641747
mutex_unlock(&mira220->mutex);
17651748

17661749
return ret;
@@ -1771,40 +1754,6 @@ static int mira220_set_stream(struct v4l2_subdev *sd, int enable)
17711754
return ret;
17721755
}
17731756

1774-
static int __maybe_unused mira220_suspend(struct device *dev)
1775-
{
1776-
struct i2c_client *client = to_i2c_client(dev);
1777-
struct v4l2_subdev *sd = i2c_get_clientdata(client);
1778-
struct mira220 *mira220 = to_mira220(sd);
1779-
1780-
if (mira220->streaming)
1781-
mira220_stop_streaming(mira220);
1782-
1783-
return 0;
1784-
}
1785-
1786-
static int __maybe_unused mira220_resume(struct device *dev)
1787-
{
1788-
struct i2c_client *client = to_i2c_client(dev);
1789-
struct v4l2_subdev *sd = i2c_get_clientdata(client);
1790-
struct mira220 *mira220 = to_mira220(sd);
1791-
int ret;
1792-
1793-
if (mira220->streaming) {
1794-
ret = mira220_start_streaming(mira220);
1795-
if (ret)
1796-
goto error;
1797-
}
1798-
1799-
return 0;
1800-
1801-
error:
1802-
mira220_stop_streaming(mira220);
1803-
mira220->streaming = false;
1804-
1805-
return ret;
1806-
}
1807-
18081757
static int mira220_get_regulators(struct mira220 *mira220)
18091758
{
18101759
struct i2c_client *client = v4l2_get_subdevdata(&mira220->sd);
@@ -1941,10 +1890,6 @@ static int mira220_init_controls(struct mira220 *mira220)
19411890
mira220->mode->hblank, mira220->mode->hblank,
19421891
1, mira220->mode->hblank);
19431892

1944-
// Make the vblank control read only. This could be changed to allow changing framerate in
1945-
// runtime, but would require adapting other settings
1946-
// mira220->vblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
1947-
19481893
// Exposure is indicated in number of lines here
19491894
// Max is determined by vblank + vsize and Tglob.
19501895
max_exposure = mira220_calculate_max_exposure_time(

0 commit comments

Comments
 (0)