Skip to content

Commit 0c6f571

Browse files
committed
resolve some remarks after code review.
1 parent 85ba1fe commit 0c6f571

File tree

4 files changed

+21
-113
lines changed

4 files changed

+21
-113
lines changed

arch/arm/boot/dts/overlays/README

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,7 +3511,6 @@ Params:
35113511
(default 16).
35123512

35133513

3514-
35153514
Name: mira220
35163515
Info: ams mira220 camera module.
35173516
Uses Unicam 1, which is the standard camera connector on most Pi
@@ -3527,7 +3526,6 @@ Params: rotation Mounting rotation of the camera sensor (0 or
35273526
Compute Module (CSI0, i2c_vc, and cam0_reg).
35283527

35293528

3530-
35313529
Name: mlx90640
35323530
Info: Overlay for i2c connected mlx90640 thermal camera
35333531
Load: dtoverlay=mlx90640
@@ -3649,7 +3647,6 @@ Params: rotation Mounting rotation of the camera sensor (0 or
36493647
Appears not to work on Pi3.
36503648

36513649

3652-
36533650
Name: papirus
36543651
Info: PaPiRus ePaper Screen by Pi Supply (both HAT and pHAT)
36553652
Load: dtoverlay=papirus,<param>=<val>

drivers/media/i2c/Kconfig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,6 @@ config VIDEO_HI847
149149
To compile this driver as a module, choose M here: the
150150
module will be called hi847.
151151

152-
config VIDEO_MIRA220
153-
tristate "ams MIRA220 sensor support"
154-
depends on I2C && VIDEO_DEV
155-
select MEDIA_CONTROLLER
156-
select VIDEO_V4L2_SUBDEV_API
157-
select V4L2_CCI_I2C
158-
select V4L2_FWNODE
159-
help
160-
This is a Video4Linux2 sensor driver for the ams
161-
MIRA220 camera.
162-
163-
To compile this driver as a module, choose M here: the
164-
module will be called mira220.
165-
166152
config VIDEO_IMX208
167153
tristate "Sony IMX208 sensor support"
168154
help
@@ -352,6 +338,20 @@ config VIDEO_IMX708
352338
config VIDEO_MAX9271_LIB
353339
tristate
354340

341+
config VIDEO_MIRA220
342+
tristate "ams MIRA220 sensor support"
343+
depends on I2C && VIDEO_DEV
344+
select MEDIA_CONTROLLER
345+
select VIDEO_V4L2_SUBDEV_API
346+
select V4L2_CCI_I2C
347+
select V4L2_FWNODE
348+
help
349+
This is a Video4Linux2 sensor driver for the ams
350+
MIRA220 camera.
351+
352+
To compile this driver as a module, choose M here: the
353+
module will be called mira220.
354+
355355
config VIDEO_MT9M001
356356
tristate "mt9m001 support"
357357
help

drivers/media/i2c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ obj-$(CONFIG_VIDEO_HI556) += hi556.o
4949
obj-$(CONFIG_VIDEO_HI846) += hi846.o
5050
obj-$(CONFIG_VIDEO_HI847) += hi847.o
5151
obj-$(CONFIG_VIDEO_I2C) += video-i2c.o
52-
obj-$(CONFIG_VIDEO_MIRA220) += mira220.o
5352
obj-$(CONFIG_VIDEO_IMX208) += imx208.o
5453
obj-$(CONFIG_VIDEO_IMX214) += imx214.o
5554
obj-$(CONFIG_VIDEO_IMX219) += imx219.o
@@ -79,6 +78,7 @@ obj-$(CONFIG_VIDEO_MAX9271_LIB) += max9271.o
7978
obj-$(CONFIG_VIDEO_MAX9286) += max9286.o
8079
obj-$(CONFIG_VIDEO_MAX96714) += max96714.o
8180
obj-$(CONFIG_VIDEO_MAX96717) += max96717.o
81+
obj-$(CONFIG_VIDEO_MIRA220) += mira220.o
8282
obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o
8383
obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
8484
obj-$(CONFIG_VIDEO_MT9M001) += mt9m001.o

drivers/media/i2c/mira220.c

Lines changed: 6 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
#define MIRA220_PIXEL_ARRAY_WIDTH 1600U
3636
#define MIRA220_PIXEL_ARRAY_HEIGHT 1400U
3737

38+
/* mira220 does not support analog gain. */
3839
#define MIRA220_ANALOG_GAIN_MIN 1
39-
#define MIRA220_ANALOG_GAIN_MAX \
40-
1 /* Fixed analog gain to 1, to avoid unexpected behavior. */
40+
#define MIRA220_ANALOG_GAIN_MAX 1
4141
#define MIRA220_ANALOG_GAIN_STEP 1
4242
#define MIRA220_ANALOG_GAIN_DEFAULT MIRA220_ANALOG_GAIN_MIN
4343

@@ -95,11 +95,6 @@
9595
#define MIRA220_XCLR_MIN_DELAY_US 100000
9696
#define MIRA220_XCLR_DELAY_RANGE_US 30
9797

98-
// Outdated. See below.
99-
// pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample
100-
// 1.0Gb/s * 2 * 2 / 12 = 357913941
101-
// #define MIRA220_PIXEL_RATE (357913941)
102-
10398
// Mira220 PIXEL_RATE is derived from ROW_LENGTH. See datasheet Section 9.2.
10499
// ROW_LENGTH is set by registers: 0x102B, 0x102C. Unit is number of CLK_IN cycles.
105100
// PIXEL_RATE = 1000000000 * WIDTH / (ROW_LENGTH * CLK_IN_PERIOD_NS)
@@ -146,16 +141,12 @@
146141
#define MIRA220_TEST_PATTERN_DISABLE 0x00
147142
#define MIRA220_TEST_PATTERN_VERTICAL_GRADIENT 0x01
148143

149-
/* Embedded metadata stream structure */
150-
#define MIRA220_EMBEDDED_LINE_WIDTH 16384
151-
#define MIRA220_NUM_EMBEDDED_LINES 1
152-
153144
/* From Jetson driver */
154145
#define MIRA220_DEFAULT_LINE_LENGTH (0xA80)
155146
#define MIRA220_DEFAULT_PIXEL_CLOCK (160)
156147
#define MIRA220_DEFAULT_FRAME_LENGTH (0x07C0) //TODO REMOVE THESE
157148

158-
enum pad_types { IMAGE_PAD, METADATA_PAD, NUM_PADS };
149+
enum pad_types { IMAGE_PAD, NUM_PADS };
159150

160151
struct mira220_reg {
161152
u16 address;
@@ -1369,8 +1360,6 @@ static int mira220_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
13691360
struct mira220 *mira220 = to_mira220(sd);
13701361
struct v4l2_mbus_framefmt *try_fmt_img =
13711362
v4l2_subdev_state_get_format(fh->state, IMAGE_PAD);
1372-
struct v4l2_mbus_framefmt *try_fmt_meta =
1373-
v4l2_subdev_state_get_format(fh->state, METADATA_PAD);
13741363
struct v4l2_rect *try_crop;
13751364

13761365
mutex_lock(&mira220->mutex);
@@ -1382,12 +1371,6 @@ static int mira220_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
13821371
mira220, supported_modes[0].code);
13831372
try_fmt_img->field = V4L2_FIELD_NONE;
13841373

1385-
/* TODO(jalv): Initialize try_fmt for the embedded metadata pad */
1386-
try_fmt_meta->width = MIRA220_EMBEDDED_LINE_WIDTH;
1387-
try_fmt_meta->height = MIRA220_NUM_EMBEDDED_LINES;
1388-
try_fmt_meta->code = MEDIA_BUS_FMT_SENSOR_DATA;
1389-
try_fmt_meta->field = V4L2_FIELD_NONE;
1390-
13911374
/* Initialize try_crop rectangle. */
13921375
try_crop = v4l2_subdev_state_get_crop(fh->state, 0);
13931376
try_crop->top = supported_modes[0].crop.top;
@@ -1527,15 +1510,7 @@ static int mira220_enum_frame_size(struct v4l2_subdev *sd,
15271510
fse->max_width = fse->min_width;
15281511
fse->min_height = supported_modes[fse->index].height;
15291512
fse->max_height = fse->min_height;
1530-
} else {
1531-
if (fse->code != MEDIA_BUS_FMT_SENSOR_DATA || fse->index > 0)
1532-
return -EINVAL;
1533-
1534-
fse->min_width = MIRA220_EMBEDDED_LINE_WIDTH;
1535-
fse->max_width = fse->min_width;
1536-
fse->min_height = MIRA220_NUM_EMBEDDED_LINES;
1537-
fse->max_height = fse->min_height;
1538-
}
1513+
}
15391514

15401515
return 0;
15411516
}
@@ -1559,13 +1534,6 @@ static void mira220_update_image_pad_format(struct mira220 *mira220,
15591534
mira220_reset_colorspace(&fmt->format);
15601535
}
15611536

1562-
static void mira220_update_metadata_pad_format(struct v4l2_subdev_format *fmt)
1563-
{
1564-
fmt->format.width = MIRA220_EMBEDDED_LINE_WIDTH;
1565-
fmt->format.height = MIRA220_NUM_EMBEDDED_LINES;
1566-
fmt->format.code = MEDIA_BUS_FMT_SENSOR_DATA;
1567-
fmt->format.field = V4L2_FIELD_NONE;
1568-
}
15691537

15701538
static int __mira220_get_pad_format(struct mira220 *mira220,
15711539
struct v4l2_subdev_state *sd_state,
@@ -1590,9 +1558,7 @@ static int __mira220_get_pad_format(struct mira220 *mira220,
15901558
fmt->format.code =
15911559
mira220_validate_format_code_or_default(
15921560
mira220, mira220->fmt.code);
1593-
} else {
1594-
mira220_update_metadata_pad_format(fmt);
1595-
}
1561+
}
15961562
}
15971563

15981564
return 0;
@@ -1686,10 +1652,7 @@ static int mira220_set_pad_format(struct v4l2_subdev *sd,
16861652
framefmt = v4l2_subdev_state_get_format(sd_state,
16871653
fmt->pad);
16881654
*framefmt = fmt->format;
1689-
} else {
1690-
/* Only one embedded data mode is supported */
1691-
mira220_update_metadata_pad_format(fmt);
1692-
}
1655+
}
16931656
}
16941657

16951658
mutex_unlock(&mira220->mutex);
@@ -2130,53 +2093,6 @@ static void mira220_free_controls(struct mira220 *mira220)
21302093
mutex_destroy(&mira220->mutex);
21312094
}
21322095

2133-
static int mira220_check_hwcfg(struct device *dev)
2134-
{
2135-
struct fwnode_handle *endpoint;
2136-
struct v4l2_fwnode_endpoint ep_cfg = { .bus_type =
2137-
V4L2_MBUS_CSI2_DPHY };
2138-
int ret = -EINVAL;
2139-
2140-
endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL);
2141-
if (!endpoint) {
2142-
dev_err(dev, "endpoint node not found\n");
2143-
return -EINVAL;
2144-
}
2145-
2146-
if (v4l2_fwnode_endpoint_alloc_parse(endpoint, &ep_cfg)) {
2147-
dev_err(dev, "could not parse endpoint\n");
2148-
goto error_out;
2149-
}
2150-
2151-
/* Check the number of MIPI CSI2 data lanes */
2152-
if (ep_cfg.bus.mipi_csi2.num_data_lanes != 2) {
2153-
dev_err(dev, "only 2 data lanes are currently supported\n");
2154-
goto error_out;
2155-
}
2156-
2157-
/* Check the link frequency set in device tree */
2158-
if (!ep_cfg.nr_of_link_frequencies) {
2159-
dev_err(dev, "link-frequency property not found in DT\n");
2160-
goto error_out;
2161-
}
2162-
2163-
if (ep_cfg.nr_of_link_frequencies != 1 ||
2164-
ep_cfg.link_frequencies[0] != MIRA220_DEFAULT_LINK_FREQ) {
2165-
dev_err(dev, "Link frequency not supported: %lld\n",
2166-
ep_cfg.link_frequencies[0]);
2167-
goto error_out;
2168-
}
2169-
2170-
// TODO(jalv): Check device tree configuration and make sure it is supported by the driver
2171-
ret = 0;
2172-
2173-
error_out:
2174-
v4l2_fwnode_endpoint_free(&ep_cfg);
2175-
fwnode_handle_put(endpoint);
2176-
2177-
return ret;
2178-
}
2179-
21802096
static int mira220_probe(struct i2c_client *client)
21812097
{
21822098
struct device *dev = &client->dev;
@@ -2192,10 +2108,6 @@ static int mira220_probe(struct i2c_client *client)
21922108
v4l2_i2c_subdev_init(&mira220->sd, client, &mira220_subdev_ops);
21932109
mira220->regmap = devm_cci_regmap_init_i2c(client, 16);
21942110

2195-
/* Check the hardware configuration in device tree */
2196-
if (mira220_check_hwcfg(dev))
2197-
return -EINVAL;
2198-
21992111
/* Parse device tree to check if dtoverlay has param skip-reg-upload=1 */
22002112
/* Set default TBD I2C device address to LED I2C Address*/
22012113

@@ -2250,7 +2162,6 @@ static int mira220_probe(struct i2c_client *client)
22502162

22512163
/* Initialize source pads */
22522164
mira220->pad[IMAGE_PAD].flags = MEDIA_PAD_FL_SOURCE;
2253-
mira220->pad[METADATA_PAD].flags = MEDIA_PAD_FL_SOURCE;
22542165

22552166

22562167
/* Initialize default format */

0 commit comments

Comments
 (0)