Skip to content

Commit d3b254b

Browse files
committed
further cleanup
1 parent 0c6f571 commit d3b254b

1 file changed

Lines changed: 17 additions & 55 deletions

File tree

drivers/media/i2c/mira220.c

Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -66,48 +66,29 @@
6666

6767
// Exposure time is indicated in number of rows
6868
#define MIRA220_EXP_TIME_REG CCI_REG16_LE(0x100C)
69-
7069
// VBLANK is indicated in number of rows
7170
#define MIRA220_VBLANK_REG CCI_REG16_LE(0x1012)
7271

7372
#define MIRA220_HFLIP_REG CCI_REG8(0x209C)
7473
#define MIRA220_HFLIP_ENABLE_MIRROR 1
7574
#define MIRA220_HFLIP_DISABLE_MIRROR 0
76-
7775
#define MIRA220_VFLIP_REG CCI_REG8(0x1095)
7876
#define MIRA220_VFLIP_ENABLE_FLIP 1
7977
#define MIRA220_VFLIP_DISABLE_FLIP 0
8078

8179
#define MIRA220_OTP_CMD_REG CCI_REG8(0x0080)
8280
#define MIRA220_OTP_CMD_UP 0x4
8381
#define MIRA220_OTP_CMD_DOWN 0x8
84-
8582
#define MIRA220_GLOB_NUM_CLK_CYCLES 1928
86-
8783
#define MIRA220_SUPPORTED_XCLK_FREQ 38400000
88-
89-
// Default exposure is adjusted to mode with smallest height
90-
#define MIRA220_DEFAULT_EXPOSURE \
91-
100 //(MIRA220_MIN_V_SIZE + MIRA220_MIN_VBLANK - MIRA220_GLOB_NUM_CLK_CYCLES / MIRA220_MIN_ROW_LENGTH) //TODO
84+
#define MIRA220_DEFAULT_EXPOSURE 1000
9285
#define MIRA220_EXPOSURE_MIN 1
9386

9487
// Power on function timing
9588
#define MIRA220_XCLR_MIN_DELAY_US 100000
96-
#define MIRA220_XCLR_DELAY_RANGE_US 30
97-
98-
// Mira220 PIXEL_RATE is derived from ROW_LENGTH. See datasheet Section 9.2.
99-
// ROW_LENGTH is set by registers: 0x102B, 0x102C. Unit is number of CLK_IN cycles.
100-
// PIXEL_RATE = 1000000000 * WIDTH / (ROW_LENGTH * CLK_IN_PERIOD_NS)
101-
// ROW_LENGTH_1600x1400_1000GBS=300
102-
// ROW_LENGTH_640x480_1000GBS=450
103-
// CLK_IN_PERIOD_NS = 1.0 s / 38.4 Mhz = 26.04 ns
104-
// MIRA220_PIXEL_RATE = 1000000000 * 1600 / (300 * 26.04) = 204813108
105-
// MIRA220_PIXEL_RATE = 1000000000 * 640 / (450 * 26.04) = 54616828
106-
#define MIRA220_PIXEL_RATE 384000000 //384M (x10)
107-
// Row time in microseconds. Not used in driver, but used in libcamera cam_helper.
108-
// ROW_TIME_US = ROW_LENGTH * CLK_IN_PERIOD_NS / 1000
109-
// MIRA220_ROW_TIME_1600x1400_1000GBS_US=(300*26.04/1000)=7.8us
110-
// MIRA220_ROW_TIME_640x480_1000GBS_US=(450*26.04/1000)=11.7us
89+
#define MIRA220_XCLR_DELAY_RANGE_US 300
90+
91+
#define MIRA220_PIXEL_RATE 10 * MIRA220_SUPPORTED_XCLK_FREQ //384M (x10)
11192

11293
/* Should match device tree link freq */
11394
#define MIRA220_DEFAULT_LINK_FREQ 750000000
@@ -129,22 +110,12 @@
129110
* HBLANK=1/((1/204813108)*30*(1400+13))-1600=3232
130111
*/
131112

132-
#define MIRA220_HBLANK_640x480_120FPS 3860
133-
#define MIRA220_HBLANK_1600x1400_30FPS 2900
134-
#define MIRA220_HBLANK_1600x1400_1500 1400
135-
136-
#define MIRA220_HBLANK_400x400_304 2640
137-
#define MIRA220_HBLANK_640x480_304 2400
138113
#define MIRA220_HBLANK_1600x1400_304 1440
139114

140115
#define MIRA220_REG_TEST_PATTERN CCI_REG8(0x2091)
141116
#define MIRA220_TEST_PATTERN_DISABLE 0x00
142117
#define MIRA220_TEST_PATTERN_VERTICAL_GRADIENT 0x01
143118

144-
/* From Jetson driver */
145-
#define MIRA220_DEFAULT_LINE_LENGTH (0xA80)
146-
#define MIRA220_DEFAULT_PIXEL_CLOCK (160)
147-
#define MIRA220_DEFAULT_FRAME_LENGTH (0x07C0) //TODO REMOVE THESE
148119

149120
enum pad_types { IMAGE_PAD, NUM_PADS };
150121

@@ -164,18 +135,11 @@ struct mira220_v4l2_reg {
164135

165136
/* Mode : resolution and related config&values */
166137
struct mira220_mode {
167-
/* Frame width */
168138
unsigned int width;
169-
/* Frame height */
170139
unsigned int height;
171-
172-
/* Analog crop rectangle. */
173140
struct v4l2_rect crop;
174-
175-
/* Default register values */
176141
struct mira220_reg_list reg_list;
177142
u32 row_length;
178-
179143
u32 pixel_rate;
180144
u32 min_vblank;
181145
u32 max_vblank;
@@ -1042,7 +1006,6 @@ static const int mira220_test_pattern_val[] = {
10421006

10431007
/* regulator supplies */
10441008
static const char *const mira220_supply_name[] = {
1045-
// TODO(jalv): Check supply names
10461009
/* Supplies can be enabled in any order */
10471010
"vana", /* Analog (2.8V) supply */
10481011
"vdig", /* Digital Core (1.8V) supply */
@@ -1086,9 +1049,9 @@ static const struct mira220_mode supported_modes[] = {
10861049
// ROW_LENGTH is configured by register 0x102B, 0x102C.
10871050
.row_length = 304,
10881051
.pixel_rate = MIRA220_PIXEL_RATE,
1089-
.min_vblank = 20, // ceil(1928 / 300) + 11
1090-
.max_vblank = 50000, // ceil(1928 / 300) + 11
1091-
.hblank = MIRA220_HBLANK_1600x1400_304, // TODO
1052+
.min_vblank = 20, // at least ceil(1928 / 300) + 11
1053+
.max_vblank = 50000,
1054+
.hblank = MIRA220_HBLANK_1600x1400_304,
10921055
.code = MEDIA_BUS_FMT_SGRBG12_1X12,
10931056
},
10941057

@@ -1233,7 +1196,6 @@ static int mira220_write_stop_streaming_regs(struct mira220 *mira220)
12331196
{
12341197
struct i2c_client *const client = v4l2_get_subdevdata(&mira220->sd);
12351198
int ret = 0;
1236-
u32 frame_time;
12371199
int try_cnt;
12381200

12391201
for (try_cnt = 0; try_cnt < 5; try_cnt++) {
@@ -1268,10 +1230,8 @@ static int mira220_write_stop_streaming_regs(struct mira220 *mira220)
12681230
* frame_time = frame length rows * Tline
12691231
* Tline = line length / pixel clock (in MHz)
12701232
*/
1271-
frame_time = MIRA220_DEFAULT_FRAME_LENGTH *
1272-
MIRA220_DEFAULT_LINE_LENGTH / MIRA220_DEFAULT_PIXEL_CLOCK;
12731233

1274-
usleep_range(frame_time, frame_time + 1000); //TODO, set to 1 frametime
1234+
usleep_range(40000, 40000+ 10000);
12751235

12761236
return ret;
12771237
}
@@ -1292,8 +1252,7 @@ static int mira220_write_exposure_reg(struct mira220 *mira220, u32 exposure)
12921252
mira220->mode->height, mira220->vblank->val,
12931253
mira220->mode->row_length);
12941254
u32 ret = 0;
1295-
u64 readval = 0;
1296-
int otherval = 0;
1255+
12971256
u32 capped_exposure = exposure;
12981257

12991258
if (exposure > max_exposure) {
@@ -1454,7 +1413,6 @@ static int mira220_set_ctrl(struct v4l2_ctrl *ctrl)
14541413

14551414
pm_runtime_put(&client->dev);
14561415

1457-
// TODO: FIXIT
14581416
return ret;
14591417
}
14601418

@@ -2214,14 +2172,18 @@ static void mira220_remove(struct i2c_client *client)
22142172
pm_runtime_set_suspended(&client->dev);
22152173
}
22162174

2175+
2176+
22172177
static const struct dev_pm_ops mira220_pm_ops = {
2218-
SET_SYSTEM_SLEEP_PM_OPS(mira220_suspend, mira220_resume)
22192178
SET_RUNTIME_PM_OPS(mira220_power_off, mira220_power_on, NULL)
22202179
};
22212180

2222-
static const struct of_device_id mira220_dt_ids[] = { { .compatible =
2223-
"ams,mira220" },
2224-
{ /* sentinel */ } };
2181+
2182+
static const struct of_device_id mira220_dt_ids[] = {
2183+
{ .compatible = "ams,mira220" },
2184+
{ /* sentinel */ }
2185+
};
2186+
22252187
MODULE_DEVICE_TABLE(of, mira220_dt_ids);
22262188

22272189
static const struct i2c_device_id mira220_ids[] = { { "mira220", 0 }, {} };

0 commit comments

Comments
 (0)