Skip to content

Commit 52a7c20

Browse files
naushirjailuthra
authored andcommitted
drivers: media: arducam_64mp: Remove legacy embedded data support
With the introduction of the streams API, the legacy embedded data support has been removed. Pull out all code associated with the legacy support. Note that this driver has not been converted to use the streams API, so embedded data will be unavailable. Signed-off-by: Naushir Patuck <[email protected]> Signed-off-by: Jacopo Mondi <[email protected]>
1 parent 6b29605 commit 52a7c20

File tree

1 file changed

+40
-105
lines changed

1 file changed

+40
-105
lines changed

drivers/media/i2c/arducam_64mp.c

Lines changed: 40 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@
9494
#define ARDUCAM_64MP_TEST_PATTERN_B_DEFAULT 0
9595
#define ARDUCAM_64MP_TEST_PATTERN_GB_DEFAULT 0
9696

97-
/* Embedded metadata stream structure */
98-
#define ARDUCAM_64MP_EMBEDDED_LINE_WIDTH (11560 * 3)
99-
#define ARDUCAM_64MP_NUM_EMBEDDED_LINES 1
100-
101-
enum pad_types {
102-
IMAGE_PAD,
103-
METADATA_PAD,
104-
NUM_PADS
105-
};
106-
10797
/* ARDUCAM_64MP native and active pixel array size. */
10898
#define ARDUCAM_64MP_NATIVE_WIDTH 9344U
10999
#define ARDUCAM_64MP_NATIVE_HEIGHT 7032U
@@ -1422,7 +1412,7 @@ static const char * const arducam_64mp_supply_name[] = {
14221412

14231413
struct arducam_64mp {
14241414
struct v4l2_subdev sd;
1425-
struct media_pad pad[NUM_PADS];
1415+
struct media_pad pad;
14261416

14271417
unsigned int fmt_code;
14281418

@@ -1555,9 +1545,7 @@ static int arducam_64mp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
15551545
{
15561546
struct arducam_64mp *arducam_64mp = to_arducam_64mp(sd);
15571547
struct v4l2_mbus_framefmt *try_fmt_img =
1558-
v4l2_subdev_state_get_format(fh->state, IMAGE_PAD);
1559-
struct v4l2_mbus_framefmt *try_fmt_meta =
1560-
v4l2_subdev_state_get_format(fh->state, METADATA_PAD);
1548+
v4l2_subdev_state_get_format(fh->state, 0);
15611549
struct v4l2_rect *try_crop;
15621550

15631551
mutex_lock(&arducam_64mp->mutex);
@@ -1568,14 +1556,8 @@ static int arducam_64mp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
15681556
try_fmt_img->code = arducam_64mp_get_format_code(arducam_64mp);
15691557
try_fmt_img->field = V4L2_FIELD_NONE;
15701558

1571-
/* Initialize try_fmt for the embedded metadata pad */
1572-
try_fmt_meta->width = ARDUCAM_64MP_EMBEDDED_LINE_WIDTH;
1573-
try_fmt_meta->height = ARDUCAM_64MP_NUM_EMBEDDED_LINES;
1574-
try_fmt_meta->code = MEDIA_BUS_FMT_SENSOR_DATA;
1575-
try_fmt_meta->field = V4L2_FIELD_NONE;
1576-
15771559
/* Initialize try_crop */
1578-
try_crop = v4l2_subdev_state_get_crop(fh->state, IMAGE_PAD);
1560+
try_crop = v4l2_subdev_state_get_crop(fh->state, 0);
15791561
try_crop->left = ARDUCAM_64MP_PIXEL_ARRAY_LEFT;
15801562
try_crop->top = ARDUCAM_64MP_PIXEL_ARRAY_TOP;
15811563
try_crop->width = ARDUCAM_64MP_PIXEL_ARRAY_WIDTH;
@@ -1731,20 +1713,13 @@ static int arducam_64mp_enum_mbus_code(struct v4l2_subdev *sd,
17311713
{
17321714
struct arducam_64mp *arducam_64mp = to_arducam_64mp(sd);
17331715

1734-
if (code->pad >= NUM_PADS)
1716+
if (code->pad >= 1)
17351717
return -EINVAL;
17361718

1737-
if (code->pad == IMAGE_PAD) {
1738-
if (code->index > 0)
1739-
return -EINVAL;
1719+
if (code->index > 0)
1720+
return -EINVAL;
17401721

1741-
code->code = arducam_64mp_get_format_code(arducam_64mp);
1742-
} else {
1743-
if (code->index > 0)
1744-
return -EINVAL;
1745-
1746-
code->code = MEDIA_BUS_FMT_SENSOR_DATA;
1747-
}
1722+
code->code = arducam_64mp_get_format_code(arducam_64mp);
17481723

17491724
return 0;
17501725
}
@@ -1755,29 +1730,19 @@ static int arducam_64mp_enum_frame_size(struct v4l2_subdev *sd,
17551730
{
17561731
struct arducam_64mp *arducam_64mp = to_arducam_64mp(sd);
17571732

1758-
if (fse->pad >= NUM_PADS)
1733+
if (fse->pad >= 1)
17591734
return -EINVAL;
17601735

1761-
if (fse->pad == IMAGE_PAD) {
1762-
if (fse->index >= ARRAY_SIZE(supported_modes))
1763-
return -EINVAL;
1764-
1765-
if (fse->code != arducam_64mp_get_format_code(arducam_64mp))
1766-
return -EINVAL;
1736+
if (fse->index >= ARRAY_SIZE(supported_modes))
1737+
return -EINVAL;
17671738

1768-
fse->min_width = supported_modes[fse->index].width;
1769-
fse->max_width = fse->min_width;
1770-
fse->min_height = supported_modes[fse->index].height;
1771-
fse->max_height = fse->min_height;
1772-
} else {
1773-
if (fse->code != MEDIA_BUS_FMT_SENSOR_DATA || fse->index > 0)
1774-
return -EINVAL;
1739+
if (fse->code != arducam_64mp_get_format_code(arducam_64mp))
1740+
return -EINVAL;
17751741

1776-
fse->min_width = ARDUCAM_64MP_EMBEDDED_LINE_WIDTH;
1777-
fse->max_width = fse->min_width;
1778-
fse->min_height = ARDUCAM_64MP_NUM_EMBEDDED_LINES;
1779-
fse->max_height = fse->min_height;
1780-
}
1742+
fse->min_width = supported_modes[fse->index].width;
1743+
fse->max_width = fse->min_width;
1744+
fse->min_height = supported_modes[fse->index].height;
1745+
fse->max_height = fse->min_height;
17811746

17821747
return 0;
17831748
}
@@ -1803,22 +1768,13 @@ arducam_64mp_update_image_pad_format(struct arducam_64mp *arducam_64mp,
18031768
arducam_64mp_reset_colorspace(&fmt->format);
18041769
}
18051770

1806-
static void
1807-
arducam_64mp_update_metadata_pad_format(struct v4l2_subdev_format *fmt)
1808-
{
1809-
fmt->format.width = ARDUCAM_64MP_EMBEDDED_LINE_WIDTH;
1810-
fmt->format.height = ARDUCAM_64MP_NUM_EMBEDDED_LINES;
1811-
fmt->format.code = MEDIA_BUS_FMT_SENSOR_DATA;
1812-
fmt->format.field = V4L2_FIELD_NONE;
1813-
}
1814-
18151771
static int arducam_64mp_get_pad_format(struct v4l2_subdev *sd,
18161772
struct v4l2_subdev_state *sd_state,
18171773
struct v4l2_subdev_format *fmt)
18181774
{
18191775
struct arducam_64mp *arducam_64mp = to_arducam_64mp(sd);
18201776

1821-
if (fmt->pad >= NUM_PADS)
1777+
if (fmt->pad >= 1)
18221778
return -EINVAL;
18231779

18241780
mutex_lock(&arducam_64mp->mutex);
@@ -1827,20 +1783,13 @@ static int arducam_64mp_get_pad_format(struct v4l2_subdev *sd,
18271783
struct v4l2_mbus_framefmt *try_fmt =
18281784
v4l2_subdev_state_get_format(sd_state, fmt->pad);
18291785
/* update the code which could change due to vflip or hflip: */
1830-
try_fmt->code = fmt->pad == IMAGE_PAD ?
1831-
arducam_64mp_get_format_code(arducam_64mp) :
1832-
MEDIA_BUS_FMT_SENSOR_DATA;
1786+
try_fmt->code = arducam_64mp_get_format_code(arducam_64mp);
18331787
fmt->format = *try_fmt;
18341788
} else {
1835-
if (fmt->pad == IMAGE_PAD) {
1836-
arducam_64mp_update_image_pad_format(arducam_64mp,
1837-
arducam_64mp->mode,
1838-
fmt);
1839-
fmt->format.code =
1840-
arducam_64mp_get_format_code(arducam_64mp);
1841-
} else {
1842-
arducam_64mp_update_metadata_pad_format(fmt);
1843-
}
1789+
arducam_64mp_update_image_pad_format(arducam_64mp,
1790+
arducam_64mp->mode, fmt);
1791+
fmt->format.code =
1792+
arducam_64mp_get_format_code(arducam_64mp);
18441793
}
18451794

18461795
mutex_unlock(&arducam_64mp->mutex);
@@ -1908,39 +1857,26 @@ static int arducam_64mp_set_pad_format(struct v4l2_subdev *sd,
19081857
const struct arducam_64mp_mode *mode;
19091858
struct arducam_64mp *arducam_64mp = to_arducam_64mp(sd);
19101859

1911-
if (fmt->pad >= NUM_PADS)
1860+
if (fmt->pad >= 1)
19121861
return -EINVAL;
19131862

19141863
mutex_lock(&arducam_64mp->mutex);
19151864

1916-
if (fmt->pad == IMAGE_PAD) {
1917-
/* Bayer order varies with flips */
1918-
fmt->format.code = arducam_64mp_get_format_code(arducam_64mp);
1919-
1920-
mode = v4l2_find_nearest_size(supported_modes,
1921-
ARRAY_SIZE(supported_modes),
1922-
width, height,
1923-
fmt->format.width,
1924-
fmt->format.height);
1925-
arducam_64mp_update_image_pad_format(arducam_64mp, mode, fmt);
1926-
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1927-
framefmt = v4l2_subdev_state_get_format(sd_state,
1928-
fmt->pad);
1929-
*framefmt = fmt->format;
1930-
} else {
1931-
arducam_64mp->mode = mode;
1932-
arducam_64mp->fmt_code = fmt->format.code;
1933-
arducam_64mp_set_framing_limits(arducam_64mp);
1934-
}
1865+
/* Bayer order varies with flips */
1866+
fmt->format.code = arducam_64mp_get_format_code(arducam_64mp);
1867+
1868+
mode = v4l2_find_nearest_size(supported_modes,
1869+
ARRAY_SIZE(supported_modes), width,
1870+
height, fmt->format.width,
1871+
fmt->format.height);
1872+
arducam_64mp_update_image_pad_format(arducam_64mp, mode, fmt);
1873+
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1874+
framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
1875+
*framefmt = fmt->format;
19351876
} else {
1936-
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1937-
framefmt = v4l2_subdev_state_get_format(sd_state,
1938-
fmt->pad);
1939-
*framefmt = fmt->format;
1940-
} else {
1941-
/* Only one embedded data mode is supported */
1942-
arducam_64mp_update_metadata_pad_format(fmt);
1943-
}
1877+
arducam_64mp->mode = mode;
1878+
arducam_64mp->fmt_code = fmt->format.code;
1879+
arducam_64mp_set_framing_limits(arducam_64mp);
19441880
}
19451881

19461882
mutex_unlock(&arducam_64mp->mutex);
@@ -2545,11 +2481,10 @@ static int arducam_64mp_probe(struct i2c_client *client)
25452481
arducam_64mp->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
25462482

25472483
/* Initialize source pads */
2548-
arducam_64mp->pad[IMAGE_PAD].flags = MEDIA_PAD_FL_SOURCE;
2549-
arducam_64mp->pad[METADATA_PAD].flags = MEDIA_PAD_FL_SOURCE;
2484+
arducam_64mp->pad.flags = MEDIA_PAD_FL_SOURCE;
25502485

2551-
ret = media_entity_pads_init(&arducam_64mp->sd.entity, NUM_PADS,
2552-
arducam_64mp->pad);
2486+
ret = media_entity_pads_init(&arducam_64mp->sd.entity, 1,
2487+
&arducam_64mp->pad);
25532488
if (ret) {
25542489
dev_err(dev, "failed to init entity pads: %d\n", ret);
25552490
goto error_handler_free;

0 commit comments

Comments
 (0)