From 92afdc1bf1f2100d6c634a131421cd112bad5a48 Mon Sep 17 00:00:00 2001 From: Kiran Padwal Date: Fri, 13 Feb 2015 05:52:10 -0300 Subject: [media] staging: dt3155v4l: Switch to using managed resource with devm_ This patch uses managed resource APIs to allocate memory in order to simplify the driver unload or failure cases Signed-off-by: Kiran Padwal Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/dt3155v4l/dt3155v4l.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c index 293ffda503e0..e60a53e744c4 100644 --- a/drivers/staging/media/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c @@ -901,14 +901,13 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (err) return -ENODEV; - pd = kzalloc(sizeof(*pd), GFP_KERNEL); + pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL); if (!pd) return -ENOMEM; pd->vdev = video_device_alloc(); - if (!pd->vdev) { - err = -ENOMEM; - goto err_video_device_alloc; - } + if (!pd->vdev) + return -ENOMEM; + *pd->vdev = dt3155_vdev; pci_set_drvdata(pdev, pd); /* for use in dt3155_remove() */ video_set_drvdata(pd->vdev, pd); /* for use in video_fops */ @@ -951,8 +950,7 @@ err_req_region: pci_disable_device(pdev); err_enable_dev: video_device_release(pd->vdev); -err_video_device_alloc: - kfree(pd); + return err; } @@ -970,7 +968,6 @@ dt3155_remove(struct pci_dev *pdev) * video_device_release() is invoked automatically * see: struct video_device dt3155_vdev */ - kfree(pd); } static const struct pci_device_id pci_ids[] = { -- cgit v1.2.1 From b6cca54fc80d54c92afa92431bfb9f8d7f9a23cd Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sun, 8 Feb 2015 19:29:11 -0300 Subject: [media] media: bcm2048: remove unused return of function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Integer return of bcm2048_parse_rds_rt () is never used, changing the return type to void. Signed-off-by: Luis de Bethencourt Acked-by: Pali Rohár Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/bcm2048/radio-bcm2048.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index 538250667918..7f3d528b6309 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -1579,7 +1579,7 @@ static void bcm2048_parse_rt_match_d(struct bcm2048_device *bdev, int i, bcm2048_parse_rds_rt_block(bdev, i, index+2, crc); } -static int bcm2048_parse_rds_rt(struct bcm2048_device *bdev) +static void bcm2048_parse_rds_rt(struct bcm2048_device *bdev) { int i, index = 0, crc, match_b = 0, match_c = 0, match_d = 0; @@ -1615,8 +1615,6 @@ static int bcm2048_parse_rds_rt(struct bcm2048_device *bdev) match_b = 1; } } - - return 0; } static void bcm2048_parse_rds_ps_block(struct bcm2048_device *bdev, int i, -- cgit v1.2.1 From 2e1328dd5a8fd1fa98bf8fca49c5e6df61797a99 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 17 Feb 2015 05:44:05 -0300 Subject: [media] radio-bcm2048: use unlocked_ioctl instead of ioctl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This driver does its own locking, so there is no need to use ioctl instead of unlocked_ioctl. Signed-off-by: Hans Verkuil Acked-by: Pali Rohár Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/bcm2048/radio-bcm2048.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index 7f3d528b6309..297ceaa89b7c 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -2272,7 +2272,7 @@ done: */ static const struct v4l2_file_operations bcm2048_fops = { .owner = THIS_MODULE, - .ioctl = video_ioctl2, + .unlocked_ioctl = video_ioctl2, /* for RDS read support */ .open = bcm2048_fops_open, .release = bcm2048_fops_release, -- cgit v1.2.1 From 3b786f13164596b2be44379442c34fbf561a78b6 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Mon, 12 Jan 2015 20:23:25 -0300 Subject: [media] mn88473: calculate the IF register values Add xtal as a configuration parameter so it can be used in the IF register value calculation. If not set in the configuration then use a default value. Signed-off-by: Benjamin Larsson Reviewed-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88473/mn88473.c | 26 +++++++++++--------------- drivers/staging/media/mn88473/mn88473_priv.h | 1 + 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c index a333744b76b9..fb0aa8d73711 100644 --- a/drivers/staging/media/mn88473/mn88473.c +++ b/drivers/staging/media/mn88473/mn88473.c @@ -30,6 +30,7 @@ static int mn88473_set_frontend(struct dvb_frontend *fe) struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret, i; u32 if_frequency; + u64 tmp; u8 delivery_system_val, if_val[3], bw_val[7]; dev_dbg(&client->dev, @@ -63,15 +64,12 @@ static int mn88473_set_frontend(struct dvb_frontend *fe) case SYS_DVBT2: if (c->bandwidth_hz <= 6000000) { /* IF 3570000 Hz, BW 6000000 Hz */ - memcpy(if_val, "\x24\x8e\x8a", 3); memcpy(bw_val, "\xe9\x55\x55\x1c\x29\x1c\x29", 7); } else if (c->bandwidth_hz <= 7000000) { /* IF 4570000 Hz, BW 7000000 Hz */ - memcpy(if_val, "\x2e\xcb\xfb", 3); memcpy(bw_val, "\xc8\x00\x00\x17\x0a\x17\x0a", 7); } else if (c->bandwidth_hz <= 8000000) { /* IF 4570000 Hz, BW 8000000 Hz */ - memcpy(if_val, "\x2e\xcb\xfb", 3); memcpy(bw_val, "\xaf\x00\x00\x11\xec\x11\xec", 7); } else { ret = -EINVAL; @@ -80,7 +78,6 @@ static int mn88473_set_frontend(struct dvb_frontend *fe) break; case SYS_DVBC_ANNEX_A: /* IF 5070000 Hz, BW 8000000 Hz */ - memcpy(if_val, "\x33\xea\xb3", 3); memcpy(bw_val, "\xaf\x00\x00\x11\xec\x11\xec", 7); break; default: @@ -105,17 +102,12 @@ static int mn88473_set_frontend(struct dvb_frontend *fe) if_frequency = 0; } - switch (if_frequency) { - case 3570000: - case 4570000: - case 5070000: - break; - default: - dev_err(&client->dev, "IF frequency %d not supported\n", - if_frequency); - ret = -EINVAL; - goto err; - } + /* Calculate IF registers ( (1<<24)*IF / Xtal ) */ + tmp = div_u64(if_frequency * (u64)(1<<24) + (dev->xtal / 2), + dev->xtal); + if_val[0] = ((tmp >> 16) & 0xff); + if_val[1] = ((tmp >> 8) & 0xff); + if_val[2] = ((tmp >> 0) & 0xff); ret = regmap_write(dev->regmap[2], 0x05, 0x00); ret = regmap_write(dev->regmap[2], 0xfb, 0x13); @@ -352,6 +344,10 @@ static int mn88473_probe(struct i2c_client *client, } dev->i2c_wr_max = config->i2c_wr_max; + if (!config->xtal) + dev->xtal = 25000000; + else + dev->xtal = config->xtal; dev->client[0] = client; dev->regmap[0] = regmap_init_i2c(dev->client[0], ®map_config); if (IS_ERR(dev->regmap[0])) { diff --git a/drivers/staging/media/mn88473/mn88473_priv.h b/drivers/staging/media/mn88473/mn88473_priv.h index 78af112fb41d..ef6f01323ac9 100644 --- a/drivers/staging/media/mn88473/mn88473_priv.h +++ b/drivers/staging/media/mn88473/mn88473_priv.h @@ -31,6 +31,7 @@ struct mn88473_dev { u16 i2c_wr_max; fe_delivery_system_t delivery_system; bool warm; /* FW running */ + u32 xtal; }; #endif -- cgit v1.2.1 From 3d945be05ac1e806af075e9315bc1b3409adae2b Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Mon, 12 Jan 2015 20:23:26 -0300 Subject: [media] mn88473: simplify bandwidth registers setting code Signed-off-by: Benjamin Larsson Reviewed-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88473/mn88473.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c index fb0aa8d73711..84bd4fa3c627 100644 --- a/drivers/staging/media/mn88473/mn88473.c +++ b/drivers/staging/media/mn88473/mn88473.c @@ -59,28 +59,13 @@ static int mn88473_set_frontend(struct dvb_frontend *fe) goto err; } - switch (c->delivery_system) { - case SYS_DVBT: - case SYS_DVBT2: - if (c->bandwidth_hz <= 6000000) { - /* IF 3570000 Hz, BW 6000000 Hz */ - memcpy(bw_val, "\xe9\x55\x55\x1c\x29\x1c\x29", 7); - } else if (c->bandwidth_hz <= 7000000) { - /* IF 4570000 Hz, BW 7000000 Hz */ - memcpy(bw_val, "\xc8\x00\x00\x17\x0a\x17\x0a", 7); - } else if (c->bandwidth_hz <= 8000000) { - /* IF 4570000 Hz, BW 8000000 Hz */ - memcpy(bw_val, "\xaf\x00\x00\x11\xec\x11\xec", 7); - } else { - ret = -EINVAL; - goto err; - } - break; - case SYS_DVBC_ANNEX_A: - /* IF 5070000 Hz, BW 8000000 Hz */ + if (c->bandwidth_hz <= 6000000) { + memcpy(bw_val, "\xe9\x55\x55\x1c\x29\x1c\x29", 7); + } else if (c->bandwidth_hz <= 7000000) { + memcpy(bw_val, "\xc8\x00\x00\x17\x0a\x17\x0a", 7); + } else if (c->bandwidth_hz <= 8000000) { memcpy(bw_val, "\xaf\x00\x00\x11\xec\x11\xec", 7); - break; - default: + } else { ret = -EINVAL; goto err; } -- cgit v1.2.1 From f7234138f14c2296c5eb6b8224abe00b507faf3f Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 4 Mar 2015 01:47:54 -0800 Subject: [media] v4l2-subdev: replace v4l2_subdev_fh by v4l2_subdev_pad_config If a subdevice pad op is called from a bridge driver, then there is no v4l2_subdev_fh struct that can be passed to the subdevice. This made it hard to use such subdevs from a bridge driver. This patch replaces the v4l2_subdev_fh pointer by a v4l2_subdev_pad_config pointer in the pad ops. This allows bridge drivers to use the various try_ pad ops by creating a v4l2_subdev_pad_config struct and passing it along to the pad op. The v4l2_subdev_get_try_* macros had to be changed because of this, so I also took the opportunity to use the full name of the v4l2_subdev_get_try_* functions in the __V4L2_SUBDEV_MK_GET_TRY macro arguments: if you now do 'git grep v4l2_subdev_get_try_format' you will actually find the header where it is defined. One remark regarding the drivers/staging/media/davinci_vpfe patches: the *_init_formats() functions assumed that fh could be NULL. However, that's not true for this driver, it's always set. This is almost certainly a copy and paste from the omap3isp driver. I've updated the code to reflect the fact that fh is never NULL. Signed-off-by: Hans Verkuil Acked-by: Lad, Prabhakar Tested-by: Lad, Prabhakar Acked-by: Laurent Pinchart Acked-by: Sakari Ailus Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 49 +++++++------- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 47 +++++++------ drivers/staging/media/davinci_vpfe/dm365_isif.c | 79 +++++++++++----------- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 57 ++++++++-------- drivers/staging/media/omap4iss/iss_csi2.c | 40 +++++------ drivers/staging/media/omap4iss/iss_ipipe.c | 42 ++++++------ drivers/staging/media/omap4iss/iss_ipipeif.c | 48 ++++++------- drivers/staging/media/omap4iss/iss_resizer.c | 42 ++++++------ 8 files changed, 200 insertions(+), 204 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index a425f71dfb97..715f1e6b8fe2 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1414,17 +1414,17 @@ static int ipipe_set_stream(struct v4l2_subdev *sd, int enable) * __ipipe_get_format() - helper function for getting ipipe format * @ipipe: pointer to ipipe private structure. * @pad: pad number. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @which: wanted subdev format. * */ static struct v4l2_mbus_framefmt * __ipipe_get_format(struct vpfe_ipipe_device *ipipe, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(&ipipe->subdev, cfg, pad); return &ipipe->formats[pad]; } @@ -1432,14 +1432,14 @@ __ipipe_get_format(struct vpfe_ipipe_device *ipipe, /* * ipipe_try_format() - Handle try format by pad subdev method * @ipipe: VPFE ipipe device. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @pad: pad num. * @fmt: pointer to v4l2 format structure. * @which : wanted subdev format */ static void ipipe_try_format(struct vpfe_ipipe_device *ipipe, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { @@ -1475,22 +1475,22 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe, /* * ipipe_set_format() - Handle set format by pads subdev method * @sd: pointer to v4l2 subdev structure - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ static int -ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __ipipe_get_format(ipipe, fh, fmt->pad, fmt->which); + format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - ipipe_try_format(ipipe, fh, fmt->pad, &fmt->format, fmt->which); + ipipe_try_format(ipipe, cfg, fmt->pad, &fmt->format, fmt->which); *format = fmt->format; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) @@ -1512,11 +1512,11 @@ ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * ipipe_get_format() - Handle get format by pads subdev method. * @sd: pointer to v4l2 subdev structure. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure. */ static int -ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); @@ -1524,7 +1524,7 @@ ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) fmt->format = ipipe->formats[fmt->pad]; else - fmt->format = *(v4l2_subdev_get_try_format(fh, fmt->pad)); + fmt->format = *(v4l2_subdev_get_try_format(sd, cfg, fmt->pad)); return 0; } @@ -1532,11 +1532,11 @@ ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * ipipe_enum_frame_size() - enum frame sizes on pads * @sd: pointer to v4l2 subdev structure. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @fse: pointer to v4l2_subdev_frame_size_enum structure. */ static int -ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); @@ -1548,7 +1548,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, format.code = fse->code; format.width = 1; format.height = 1; - ipipe_try_format(ipipe, fh, fse->pad, &format, + ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->min_width = format.width; fse->min_height = format.height; @@ -1559,7 +1559,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, format.code = fse->code; format.width = -1; format.height = -1; - ipipe_try_format(ipipe, fh, fse->pad, &format, + ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->max_width = format.width; fse->max_height = format.height; @@ -1570,11 +1570,11 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * ipipe_enum_mbus_code() - enum mbus codes for pads * @sd: pointer to v4l2 subdev structure. - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_mbus_code_enum structure */ static int -ipipe_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +ipipe_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { switch (code->pad) { @@ -1630,9 +1630,8 @@ static int ipipe_s_ctrl(struct v4l2_ctrl *ctrl) * @sd: pointer to v4l2 subdev structure. * @fh: V4L2 subdev file handle * - * Initialize all pad formats with default values. If fh is not NULL, try - * formats are initialized on the file handle. Otherwise active formats are - * initialized on the device. + * Initialize all pad formats with default values. Try formats are initialized + * on the file handle. */ static int ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) @@ -1641,19 +1640,19 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) memset(&format, 0, sizeof(format)); format.pad = IPIPE_PAD_SINK; - format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + format.which = V4L2_SUBDEV_FORMAT_TRY; format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; - ipipe_set_format(sd, fh, &format); + ipipe_set_format(sd, fh->pad, &format); memset(&format, 0, sizeof(format)); format.pad = IPIPE_PAD_SOURCE; - format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + format.which = V4L2_SUBDEV_FORMAT_TRY; format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; - ipipe_set_format(sd, fh, &format); + ipipe_set_format(sd, fh->pad, &format); return 0; } diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index 87d42e18377d..68a9bb04922a 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -544,12 +544,12 @@ static int ipipeif_set_stream(struct v4l2_subdev *sd, int enable) /* * ipipeif_enum_mbus_code() - Handle pixel format enumeration * @sd: pointer to v4l2 subdev structure - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_mbus_code_enum structure * return -EINVAL or zero on success */ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { switch (code->pad) { @@ -577,11 +577,11 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, /* * ipipeif_get_format() - Handle get format by pads subdev method * @sd: pointer to v4l2 subdev structure - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure */ static int -ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); @@ -589,7 +589,7 @@ ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) fmt->format = ipipeif->formats[fmt->pad]; else - fmt->format = *(v4l2_subdev_get_try_format(fh, fmt->pad)); + fmt->format = *(v4l2_subdev_get_try_format(sd, cfg, fmt->pad)); return 0; } @@ -600,14 +600,14 @@ ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * ipipeif_try_format() - Handle try format by pad subdev method * @ipipeif: VPFE ipipeif device. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @pad: pad num. * @fmt: pointer to v4l2 format structure. * @which : wanted subdev format */ static void ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { @@ -641,7 +641,7 @@ ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif, } static int -ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); @@ -653,7 +653,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, format.code = fse->code; format.width = 1; format.height = 1; - ipipeif_try_format(ipipeif, fh, fse->pad, &format, + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->min_width = format.width; fse->min_height = format.height; @@ -664,7 +664,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, format.code = fse->code; format.width = -1; format.height = -1; - ipipeif_try_format(ipipeif, fh, fse->pad, &format, + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->max_width = format.width; fse->max_height = format.height; @@ -675,18 +675,18 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * __ipipeif_get_format() - helper function for getting ipipeif format * @ipipeif: pointer to ipipeif private structure. + * @cfg: V4L2 subdev pad config * @pad: pad number. - * @fh: V4L2 subdev file handle. * @which: wanted subdev format. * */ static struct v4l2_mbus_framefmt * __ipipeif_get_format(struct vpfe_ipipeif_device *ipipeif, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(&ipipeif->subdev, cfg, pad); return &ipipeif->formats[pad]; } @@ -694,22 +694,22 @@ __ipipeif_get_format(struct vpfe_ipipeif_device *ipipeif, /* * ipipeif_set_format() - Handle set format by pads subdev method * @sd: pointer to v4l2 subdev structure - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ static int -ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __ipipeif_get_format(ipipeif, fh, fmt->pad, fmt->which); + format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - ipipeif_try_format(ipipeif, fh, fmt->pad, &fmt->format, fmt->which); + ipipeif_try_format(ipipeif, cfg, fmt->pad, &fmt->format, fmt->which); *format = fmt->format; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) @@ -757,9 +757,8 @@ static void ipipeif_set_default_config(struct vpfe_ipipeif_device *ipipeif) * @sd: VPFE ipipeif V4L2 subdevice * @fh: V4L2 subdev file handle * - * Initialize all pad formats with default values. If fh is not NULL, try - * formats are initialized on the file handle. Otherwise active formats are - * initialized on the device. + * Initialize all pad formats with default values. Try formats are initialized + * on the file handle. */ static int ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) @@ -769,19 +768,19 @@ ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) memset(&format, 0, sizeof(format)); format.pad = IPIPEIF_PAD_SINK; - format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + format.which = V4L2_SUBDEV_FORMAT_TRY; format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; - ipipeif_set_format(sd, fh, &format); + ipipeif_set_format(sd, fh->pad, &format); memset(&format, 0, sizeof(format)); format.pad = IPIPEIF_PAD_SOURCE; - format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + format.which = V4L2_SUBDEV_FORMAT_TRY; format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; - ipipeif_set_format(sd, fh, &format); + ipipeif_set_format(sd, fh->pad, &format); ipipeif_set_default_config(ipipeif); diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index bcf762bc233d..02b6bdc0d771 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -278,11 +278,11 @@ isif_config_format(struct vpfe_device *vpfe_dev, unsigned int pad) /* * isif_try_format() - Try video format on a pad * @isif: VPFE isif device - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure */ static void -isif_try_format(struct vpfe_isif_device *isif, struct v4l2_subdev_fh *fh, +isif_try_format(struct vpfe_isif_device *isif, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { unsigned int width = fmt->format.width; @@ -1394,11 +1394,11 @@ static int isif_set_stream(struct v4l2_subdev *sd, int enable) * __isif_get_format() - helper function for getting isif format * @isif: pointer to isif private structure. * @pad: pad number. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @which: wanted subdev format. */ static struct v4l2_mbus_framefmt * -__isif_get_format(struct vpfe_isif_device *isif, struct v4l2_subdev_fh *fh, +__isif_get_format(struct vpfe_isif_device *isif, struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) { @@ -1407,32 +1407,32 @@ __isif_get_format(struct vpfe_isif_device *isif, struct v4l2_subdev_fh *fh, fmt.pad = pad; fmt.which = which; - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(&isif->subdev, cfg, pad); } return &isif->formats[pad]; } /* -* isif_set_format() - set format on pad -* @sd : VPFE ISIF device -* @fh : V4L2 subdev file handle -* @fmt : pointer to v4l2 subdev format structure -* -* Return 0 on success or -EINVAL if format or pad is invalid -*/ + * isif_set_format() - set format on pad + * @sd : VPFE ISIF device + * @cfg : V4L2 subdev pad config + * @fmt : pointer to v4l2 subdev format structure + * + * Return 0 on success or -EINVAL if format or pad is invalid + */ static int -isif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +isif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); struct vpfe_device *vpfe_dev = to_vpfe_device(isif); struct v4l2_mbus_framefmt *format; - format = __isif_get_format(isif, fh, fmt->pad, fmt->which); + format = __isif_get_format(isif, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - isif_try_format(isif, fh, fmt); + isif_try_format(isif, cfg, fmt); memcpy(format, &fmt->format, sizeof(*format)); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) @@ -1447,20 +1447,20 @@ isif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * isif_get_format() - Retrieve the video format on a pad * @sd: VPFE ISIF V4L2 subdevice - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure * * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ static int -isif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +isif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __isif_get_format(vpfe_isif, fh, fmt->pad, fmt->which); + format = __isif_get_format(vpfe_isif, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; @@ -1472,11 +1472,11 @@ isif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * isif_enum_frame_size() - enum frame sizes on pads * @sd: VPFE isif V4L2 subdevice - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_frame_size_enum structure */ static int -isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); @@ -1490,7 +1490,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, format.format.width = 1; format.format.height = 1; format.which = V4L2_SUBDEV_FORMAT_TRY; - isif_try_format(isif, fh, &format); + isif_try_format(isif, cfg, &format); fse->min_width = format.format.width; fse->min_height = format.format.height; @@ -1502,7 +1502,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, format.format.width = -1; format.format.height = -1; format.which = V4L2_SUBDEV_FORMAT_TRY; - isif_try_format(isif, fh, &format); + isif_try_format(isif, cfg, &format); fse->max_width = format.format.width; fse->max_height = format.format.height; @@ -1512,11 +1512,11 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * isif_enum_mbus_code() - enum mbus codes for pads * @sd: VPFE isif V4L2 subdevice - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_mbus_code_enum structure */ static int -isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { switch (code->pad) { @@ -1537,14 +1537,14 @@ isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * isif_pad_set_selection() - set crop rectangle on pad * @sd: VPFE isif V4L2 subdevice - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_mbus_code_enum structure * * Return 0 on success, -EINVAL if pad is invalid */ static int isif_pad_set_selection(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_selection *sel) { struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); @@ -1554,7 +1554,7 @@ isif_pad_set_selection(struct v4l2_subdev *sd, if (sel->pad != ISIF_PAD_SINK || sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - format = __isif_get_format(vpfe_isif, fh, sel->pad, sel->which); + format = __isif_get_format(vpfe_isif, cfg, sel->pad, sel->which); if (format == NULL) return -EINVAL; @@ -1577,7 +1577,7 @@ isif_pad_set_selection(struct v4l2_subdev *sd, } else { struct v4l2_rect *rect; - rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK); + rect = v4l2_subdev_get_try_crop(sd, cfg, ISIF_PAD_SINK); memcpy(rect, &vpfe_isif->crop, sizeof(*rect)); } return 0; @@ -1586,14 +1586,14 @@ isif_pad_set_selection(struct v4l2_subdev *sd, /* * isif_pad_get_selection() - get crop rectangle on pad * @sd: VPFE isif V4L2 subdevice - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_mbus_code_enum structure * * Return 0 on success, -EINVAL if pad is invalid */ static int isif_pad_get_selection(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_selection *sel) { struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); @@ -1605,7 +1605,7 @@ isif_pad_get_selection(struct v4l2_subdev *sd, if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { struct v4l2_rect *rect; - rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK); + rect = v4l2_subdev_get_try_crop(sd, cfg, ISIF_PAD_SINK); memcpy(&sel->r, rect, sizeof(*rect)); } else { sel->r = vpfe_isif->crop; @@ -1619,9 +1619,8 @@ isif_pad_get_selection(struct v4l2_subdev *sd, * @sd: VPFE isif V4L2 subdevice * @fh: V4L2 subdev file handle * - * Initialize all pad formats with default values. If fh is not NULL, try - * formats are initialized on the file handle. Otherwise active formats are - * initialized on the device. + * Initialize all pad formats with default values. Try formats are initialized + * on the file handle. */ static int isif_init_formats(struct v4l2_subdev *sd, @@ -1632,27 +1631,27 @@ isif_init_formats(struct v4l2_subdev *sd, memset(&format, 0, sizeof(format)); format.pad = ISIF_PAD_SINK; - format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + format.which = V4L2_SUBDEV_FORMAT_TRY; format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; format.format.width = MAX_WIDTH; format.format.height = MAX_HEIGHT; - isif_set_format(sd, fh, &format); + isif_set_format(sd, fh->pad, &format); memset(&format, 0, sizeof(format)); format.pad = ISIF_PAD_SOURCE; - format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + format.which = V4L2_SUBDEV_FORMAT_TRY; format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; format.format.width = MAX_WIDTH; format.format.height = MAX_HEIGHT; - isif_set_format(sd, fh, &format); + isif_set_format(sd, fh->pad, &format); memset(&sel, 0, sizeof(sel)); sel.pad = ISIF_PAD_SINK; - sel.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + sel.which = V4L2_SUBDEV_FORMAT_TRY; sel.target = V4L2_SEL_TGT_CROP; sel.r.width = MAX_WIDTH; sel.r.height = MAX_HEIGHT; - isif_pad_set_selection(sd, fh, &sel); + isif_pad_set_selection(sd, fh->pad, &sel); return 0; } diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 75e70e14b724..acd9cb56f0f3 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1289,19 +1289,19 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable) /* * __resizer_get_format() - helper function for getting resizer format * @sd: pointer to subdev. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @pad: pad number. * @which: wanted subdev format. * Retun wanted mbus frame format. */ static struct v4l2_mbus_framefmt * -__resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +__resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd); if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(sd, cfg, pad); if (&resizer->crop_resizer.subdev == sd) return &resizer->crop_resizer.formats[pad]; if (&resizer->resizer_a.subdev == sd) @@ -1314,13 +1314,13 @@ __resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * resizer_try_format() - Handle try format by pad subdev method * @sd: pointer to subdev. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @pad: pad num. * @fmt: pointer to v4l2 format structure. * @which: wanted subdev format. */ static void -resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, unsigned int pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { @@ -1388,21 +1388,21 @@ resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * resizer_set_format() - Handle set format by pads subdev method * @sd: pointer to v4l2 subdev structure - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __resizer_get_format(sd, fh, fmt->pad, fmt->which); + format = __resizer_get_format(sd, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - resizer_try_format(sd, fh, fmt->pad, &fmt->format, fmt->which); + resizer_try_format(sd, cfg, fmt->pad, &fmt->format, fmt->which); *format = fmt->format; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) @@ -1448,16 +1448,16 @@ static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * resizer_get_format() - Retrieve the video format on a pad * @sd: pointer to v4l2 subdev structure. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct v4l2_mbus_framefmt *format; - format = __resizer_get_format(sd, fh, fmt->pad, fmt->which); + format = __resizer_get_format(sd, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; @@ -1469,11 +1469,11 @@ static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * resizer_enum_frame_size() - enum frame sizes on pads * @sd: Pointer to subdevice. - * @fh: V4L2 subdev file handle. + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_frame_size_enum structure. */ static int resizer_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct v4l2_mbus_framefmt format; @@ -1484,7 +1484,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - resizer_try_format(sd, fh, fse->pad, &format, + resizer_try_format(sd, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->min_width = format.width; fse->min_height = format.height; @@ -1495,7 +1495,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - resizer_try_format(sd, fh, fse->pad, &format, + resizer_try_format(sd, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->max_width = format.width; fse->max_height = format.height; @@ -1506,11 +1506,11 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, /* * resizer_enum_mbus_code() - enum mbus codes for pads * @sd: Pointer to subdevice. - * @fh: V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code: pointer to v4l2_subdev_mbus_code_enum structure */ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { if (code->pad == RESIZER_PAD_SINK) { @@ -1533,14 +1533,13 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, * @sd: Pointer to subdevice. * @fh: V4L2 subdev file handle. * - * Initialize all pad formats with default values. If fh is not NULL, try - * formats are initialized on the file handle. Otherwise active formats are - * initialized on the device. + * Initialize all pad formats with default values. Try formats are + * initialized on the file handle. */ static int resizer_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) { - __u32 which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + __u32 which = V4L2_SUBDEV_FORMAT_TRY; struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_subdev_format format; @@ -1551,7 +1550,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_YUYV8_2X8; format.format.width = MAX_IN_WIDTH; format.format.height = MAX_IN_HEIGHT; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh->pad, &format); memset(&format, 0, sizeof(format)); format.pad = RESIZER_CROP_PAD_SOURCE; @@ -1559,7 +1558,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; format.format.width = MAX_IN_WIDTH; format.format.height = MAX_IN_WIDTH; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh->pad, &format); memset(&format, 0, sizeof(format)); format.pad = RESIZER_CROP_PAD_SOURCE2; @@ -1567,7 +1566,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; format.format.width = MAX_IN_WIDTH; format.format.height = MAX_IN_WIDTH; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh->pad, &format); } else if (&resizer->resizer_a.subdev == sd) { memset(&format, 0, sizeof(format)); format.pad = RESIZER_PAD_SINK; @@ -1575,7 +1574,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_YUYV8_2X8; format.format.width = MAX_IN_WIDTH; format.format.height = MAX_IN_HEIGHT; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh->pad, &format); memset(&format, 0, sizeof(format)); format.pad = RESIZER_PAD_SOURCE; @@ -1583,7 +1582,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh->pad, &format); } else if (&resizer->resizer_b.subdev == sd) { memset(&format, 0, sizeof(format)); format.pad = RESIZER_PAD_SINK; @@ -1591,7 +1590,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_YUYV8_2X8; format.format.width = MAX_IN_WIDTH; format.format.height = MAX_IN_HEIGHT; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh->pad, &format); memset(&format, 0, sizeof(format)); format.pad = RESIZER_PAD_SOURCE; @@ -1599,7 +1598,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; format.format.width = IPIPE_MAX_OUTPUT_WIDTH_B; format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_B; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh->pad, &format); } return 0; diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index 2d96fb3eca53..e404ad4fd987 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -828,17 +828,17 @@ static const struct iss_video_operations csi2_issvideo_ops = { */ static struct v4l2_mbus_framefmt * -__csi2_get_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh, +__csi2_get_format(struct iss_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad); return &csi2->formats[pad]; } static void -csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh, +csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg, unsigned int pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { @@ -868,7 +868,7 @@ csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh, * compression. */ pixelcode = fmt->code; - format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK, which); + format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK, which); memcpy(fmt, format, sizeof(*fmt)); /* @@ -889,12 +889,12 @@ csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh, /* * csi2_enum_mbus_code - Handle pixel format enumeration * @sd : pointer to v4l2 subdev structure - * @fh : V4L2 subdev file handle + * @cfg : V4L2 subdev pad config * @code : pointer to v4l2_subdev_mbus_code_enum structure * return -EINVAL or zero on success */ static int csi2_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); @@ -907,7 +907,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd, code->code = csi2_input_fmts[code->index]; } else { - format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK, + format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK, V4L2_SUBDEV_FORMAT_TRY); switch (code->index) { case 0: @@ -931,7 +931,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd, } static int csi2_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); @@ -943,7 +943,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->min_width = format.width; fse->min_height = format.height; @@ -953,7 +953,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->max_width = format.width; fse->max_height = format.height; @@ -963,17 +963,17 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd, /* * csi2_get_format - Handle get format by pads subdev method * @sd : pointer to v4l2 subdev structure - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which); + format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; @@ -984,29 +984,29 @@ static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * csi2_set_format - Handle set format by pads subdev method * @sd : pointer to v4l2 subdev structure - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which); + format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - csi2_try_format(csi2, fh, fmt->pad, &fmt->format, fmt->which); + csi2_try_format(csi2, cfg, fmt->pad, &fmt->format, fmt->which); *format = fmt->format; /* Propagate the format from sink to source */ if (fmt->pad == CSI2_PAD_SINK) { - format = __csi2_get_format(csi2, fh, CSI2_PAD_SOURCE, + format = __csi2_get_format(csi2, cfg, CSI2_PAD_SOURCE, fmt->which); *format = fmt->format; - csi2_try_format(csi2, fh, CSI2_PAD_SOURCE, format, fmt->which); + csi2_try_format(csi2, cfg, CSI2_PAD_SOURCE, format, fmt->which); } return 0; @@ -1048,7 +1048,7 @@ static int csi2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; format.format.width = 4096; format.format.height = 4096; - csi2_set_format(sd, fh, &format); + csi2_set_format(sd, fh ? fh->pad : NULL, &format); return 0; } diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c index a1a46ef8319b..fc319822a33e 100644 --- a/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/drivers/staging/media/omap4iss/iss_ipipe.c @@ -24,7 +24,7 @@ #include "iss_ipipe.h" static struct v4l2_mbus_framefmt * -__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, +__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which); static const unsigned int ipipe_fmts[] = { @@ -176,11 +176,11 @@ static int ipipe_set_stream(struct v4l2_subdev *sd, int enable) } static struct v4l2_mbus_framefmt * -__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, +__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(&ipipe->subdev, cfg, pad); return &ipipe->formats[pad]; } @@ -188,12 +188,12 @@ __ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, /* * ipipe_try_format - Try video format on a pad * @ipipe: ISS IPIPE device - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @pad: Pad number * @fmt: Format */ static void -ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, +ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg, unsigned int pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { @@ -220,7 +220,7 @@ ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, break; case IPIPE_PAD_SOURCE_VP: - format = __ipipe_get_format(ipipe, fh, IPIPE_PAD_SINK, which); + format = __ipipe_get_format(ipipe, cfg, IPIPE_PAD_SINK, which); memcpy(fmt, format, sizeof(*fmt)); fmt->code = MEDIA_BUS_FMT_UYVY8_1X16; @@ -236,12 +236,12 @@ ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, /* * ipipe_enum_mbus_code - Handle pixel format enumeration * @sd : pointer to v4l2 subdev structure - * @fh : V4L2 subdev file handle + * @cfg : V4L2 subdev pad config * @code : pointer to v4l2_subdev_mbus_code_enum structure * return -EINVAL or zero on success */ static int ipipe_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { switch (code->pad) { @@ -268,7 +268,7 @@ static int ipipe_enum_mbus_code(struct v4l2_subdev *sd, } static int ipipe_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); @@ -280,7 +280,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - ipipe_try_format(ipipe, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->min_width = format.width; fse->min_height = format.height; @@ -290,7 +290,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - ipipe_try_format(ipipe, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->max_width = format.width; fse->max_height = format.height; @@ -300,19 +300,19 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd, /* * ipipe_get_format - Retrieve the video format on a pad * @sd : ISP IPIPE V4L2 subdevice - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: Format * * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __ipipe_get_format(ipipe, fh, fmt->pad, fmt->which); + format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; @@ -323,31 +323,31 @@ static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * ipipe_set_format - Set the video format on a pad * @sd : ISP IPIPE V4L2 subdevice - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: Format * * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __ipipe_get_format(ipipe, fh, fmt->pad, fmt->which); + format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - ipipe_try_format(ipipe, fh, fmt->pad, &fmt->format, fmt->which); + ipipe_try_format(ipipe, cfg, fmt->pad, &fmt->format, fmt->which); *format = fmt->format; /* Propagate the format from sink to source */ if (fmt->pad == IPIPE_PAD_SINK) { - format = __ipipe_get_format(ipipe, fh, IPIPE_PAD_SOURCE_VP, + format = __ipipe_get_format(ipipe, cfg, IPIPE_PAD_SOURCE_VP, fmt->which); *format = fmt->format; - ipipe_try_format(ipipe, fh, IPIPE_PAD_SOURCE_VP, format, + ipipe_try_format(ipipe, cfg, IPIPE_PAD_SOURCE_VP, format, fmt->which); } @@ -388,7 +388,7 @@ static int ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; format.format.width = 4096; format.format.height = 4096; - ipipe_set_format(sd, fh, &format); + ipipe_set_format(sd, fh ? fh->pad : NULL, &format); return 0; } diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 3943fae699ee..948edcca8704 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -361,24 +361,24 @@ static int ipipeif_set_stream(struct v4l2_subdev *sd, int enable) static struct v4l2_mbus_framefmt * __ipipeif_get_format(struct iss_ipipeif_device *ipipeif, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(&ipipeif->subdev, cfg, pad); return &ipipeif->formats[pad]; } /* * ipipeif_try_format - Try video format on a pad * @ipipeif: ISS IPIPEIF device - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @pad: Pad number * @fmt: Format */ static void ipipeif_try_format(struct iss_ipipeif_device *ipipeif, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { @@ -407,7 +407,7 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif, break; case IPIPEIF_PAD_SOURCE_ISIF_SF: - format = __ipipeif_get_format(ipipeif, fh, IPIPEIF_PAD_SINK, + format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SINK, which); memcpy(fmt, format, sizeof(*fmt)); @@ -422,7 +422,7 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif, break; case IPIPEIF_PAD_SOURCE_VP: - format = __ipipeif_get_format(ipipeif, fh, IPIPEIF_PAD_SINK, + format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SINK, which); memcpy(fmt, format, sizeof(*fmt)); @@ -441,12 +441,12 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif, /* * ipipeif_enum_mbus_code - Handle pixel format enumeration * @sd : pointer to v4l2 subdev structure - * @fh : V4L2 subdev file handle + * @cfg : V4L2 subdev pad config * @code : pointer to v4l2_subdev_mbus_code_enum structure * return -EINVAL or zero on success */ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); @@ -466,7 +466,7 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, if (code->index != 0) return -EINVAL; - format = __ipipeif_get_format(ipipeif, fh, IPIPEIF_PAD_SINK, + format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SINK, V4L2_SUBDEV_FORMAT_TRY); code->code = format->code; @@ -480,7 +480,7 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, } static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); @@ -492,7 +492,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - ipipeif_try_format(ipipeif, fh, fse->pad, &format, + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->min_width = format.width; fse->min_height = format.height; @@ -503,7 +503,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - ipipeif_try_format(ipipeif, fh, fse->pad, &format, + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->max_width = format.width; fse->max_height = format.height; @@ -514,19 +514,19 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, /* * ipipeif_get_format - Retrieve the video format on a pad * @sd : ISP IPIPEIF V4L2 subdevice - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: Format * * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __ipipeif_get_format(ipipeif, fh, fmt->pad, fmt->which); + format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; @@ -537,39 +537,39 @@ static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * ipipeif_set_format - Set the video format on a pad * @sd : ISP IPIPEIF V4L2 subdevice - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: Format * * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __ipipeif_get_format(ipipeif, fh, fmt->pad, fmt->which); + format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - ipipeif_try_format(ipipeif, fh, fmt->pad, &fmt->format, fmt->which); + ipipeif_try_format(ipipeif, cfg, fmt->pad, &fmt->format, fmt->which); *format = fmt->format; /* Propagate the format from sink to source */ if (fmt->pad == IPIPEIF_PAD_SINK) { - format = __ipipeif_get_format(ipipeif, fh, + format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SOURCE_ISIF_SF, fmt->which); *format = fmt->format; - ipipeif_try_format(ipipeif, fh, IPIPEIF_PAD_SOURCE_ISIF_SF, + ipipeif_try_format(ipipeif, cfg, IPIPEIF_PAD_SOURCE_ISIF_SF, format, fmt->which); - format = __ipipeif_get_format(ipipeif, fh, + format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SOURCE_VP, fmt->which); *format = fmt->format; - ipipeif_try_format(ipipeif, fh, IPIPEIF_PAD_SOURCE_VP, format, + ipipeif_try_format(ipipeif, cfg, IPIPEIF_PAD_SOURCE_VP, format, fmt->which); } @@ -612,7 +612,7 @@ static int ipipeif_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; format.format.width = 4096; format.format.height = 4096; - ipipeif_set_format(sd, fh, &format); + ipipeif_set_format(sd, fh ? fh->pad : NULL, &format); return 0; } diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index 3ab972818f1b..f9b0aac91e9d 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -420,24 +420,24 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable) static struct v4l2_mbus_framefmt * __resizer_get_format(struct iss_resizer_device *resizer, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format(fh, pad); + return v4l2_subdev_get_try_format(&resizer->subdev, cfg, pad); return &resizer->formats[pad]; } /* * resizer_try_format - Try video format on a pad * @resizer: ISS RESIZER device - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @pad: Pad number * @fmt: Format */ static void resizer_try_format(struct iss_resizer_device *resizer, - struct v4l2_subdev_fh *fh, unsigned int pad, + struct v4l2_subdev_pad_config *cfg, unsigned int pad, struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { @@ -465,7 +465,7 @@ resizer_try_format(struct iss_resizer_device *resizer, case RESIZER_PAD_SOURCE_MEM: pixelcode = fmt->code; - format = __resizer_get_format(resizer, fh, RESIZER_PAD_SINK, + format = __resizer_get_format(resizer, cfg, RESIZER_PAD_SINK, which); memcpy(fmt, format, sizeof(*fmt)); @@ -492,12 +492,12 @@ resizer_try_format(struct iss_resizer_device *resizer, /* * resizer_enum_mbus_code - Handle pixel format enumeration * @sd : pointer to v4l2 subdev structure - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @code : pointer to v4l2_subdev_mbus_code_enum structure * return -EINVAL or zero on success */ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); @@ -512,7 +512,7 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, break; case RESIZER_PAD_SOURCE_MEM: - format = __resizer_get_format(resizer, fh, RESIZER_PAD_SINK, + format = __resizer_get_format(resizer, cfg, RESIZER_PAD_SINK, V4L2_SUBDEV_FORMAT_TRY); if (code->index == 0) { @@ -542,7 +542,7 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, } static int resizer_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_fh *fh, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); @@ -554,7 +554,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - resizer_try_format(resizer, fh, fse->pad, &format, + resizer_try_format(resizer, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->min_width = format.width; fse->min_height = format.height; @@ -565,7 +565,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - resizer_try_format(resizer, fh, fse->pad, &format, + resizer_try_format(resizer, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); fse->max_width = format.width; fse->max_height = format.height; @@ -576,19 +576,19 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, /* * resizer_get_format - Retrieve the video format on a pad * @sd : ISP RESIZER V4L2 subdevice - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: Format * * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __resizer_get_format(resizer, fh, fmt->pad, fmt->which); + format = __resizer_get_format(resizer, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; @@ -599,32 +599,32 @@ static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* * resizer_set_format - Set the video format on a pad * @sd : ISP RESIZER V4L2 subdevice - * @fh : V4L2 subdev file handle + * @cfg: V4L2 subdev pad config * @fmt: Format * * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, +static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; - format = __resizer_get_format(resizer, fh, fmt->pad, fmt->which); + format = __resizer_get_format(resizer, cfg, fmt->pad, fmt->which); if (format == NULL) return -EINVAL; - resizer_try_format(resizer, fh, fmt->pad, &fmt->format, fmt->which); + resizer_try_format(resizer, cfg, fmt->pad, &fmt->format, fmt->which); *format = fmt->format; /* Propagate the format from sink to source */ if (fmt->pad == RESIZER_PAD_SINK) { - format = __resizer_get_format(resizer, fh, + format = __resizer_get_format(resizer, cfg, RESIZER_PAD_SOURCE_MEM, fmt->which); *format = fmt->format; - resizer_try_format(resizer, fh, RESIZER_PAD_SOURCE_MEM, format, + resizer_try_format(resizer, cfg, RESIZER_PAD_SOURCE_MEM, format, fmt->which); } @@ -667,7 +667,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd, format.format.code = MEDIA_BUS_FMT_UYVY8_1X16; format.format.width = 4096; format.format.height = 4096; - resizer_set_format(sd, fh, &format); + resizer_set_format(sd, fh ? fh->pad : NULL, &format); return 0; } -- cgit v1.2.1 From 3f1ccf16f3ea015e57c326c2b14010bf119b6184 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 4 Mar 2015 01:47:57 -0800 Subject: [media] v4l2-subdev: support new 'which' field in enum_mbus_code Support the new 'which' field in the enum_mbus_code ops. Most drivers do not need to be changed since they always return the same enumeration regardless of the 'which' field. Signed-off-by: Hans Verkuil Acked-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss_csi2.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index e404ad4fd987..2d5079deb631 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -908,7 +908,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd, code->code = csi2_input_fmts[code->index]; } else { format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK, - V4L2_SUBDEV_FORMAT_TRY); + code->which); switch (code->index) { case 0: /* Passthrough sink pad code */ diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 948edcca8704..b8e7277499d2 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -467,7 +467,7 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, return -EINVAL; format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SINK, - V4L2_SUBDEV_FORMAT_TRY); + code->which); code->code = format->code; break; diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index f9b0aac91e9d..075b876e8e68 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -513,7 +513,7 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, case RESIZER_PAD_SOURCE_MEM: format = __resizer_get_format(resizer, cfg, RESIZER_PAD_SINK, - V4L2_SUBDEV_FORMAT_TRY); + code->which); if (code->index == 0) { code->code = format->code; -- cgit v1.2.1 From 5778e749c152567ac15201fcd988bc1604878021 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 4 Mar 2015 01:47:58 -0800 Subject: [media] v4l2-subdev: add support for the new enum_frame_size 'which' field Support the new 'which' field in the enum_frame_size ops. Most drivers do not need to be changed since they always returns the same enumeration regardless of the 'which' field. Signed-off-by: Hans Verkuil Acked-by: Lad, Prabhakar Tested-by: Lad, Prabhakar Acked-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Acked-by: Andrzej Hajda Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 6 ++---- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 6 ++---- drivers/staging/media/davinci_vpfe/dm365_isif.c | 4 ++-- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 6 ++---- drivers/staging/media/omap4iss/iss_csi2.c | 4 ++-- drivers/staging/media/omap4iss/iss_ipipe.c | 4 ++-- drivers/staging/media/omap4iss/iss_ipipeif.c | 6 ++---- drivers/staging/media/omap4iss/iss_resizer.c | 6 ++---- 8 files changed, 16 insertions(+), 26 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 715f1e6b8fe2..1bbb90ce0086 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1548,8 +1548,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg format.code = fse->code; format.width = 1; format.height = 1; - ipipe_try_format(ipipe, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which); fse->min_width = format.width; fse->min_height = format.height; @@ -1559,8 +1558,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg format.code = fse->code; format.width = -1; format.height = -1; - ipipe_try_format(ipipe, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which); fse->max_width = format.width; fse->max_height = format.height; diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index 68a9bb04922a..0495bccd5172 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -653,8 +653,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *c format.code = fse->code; format.width = 1; format.height = 1; - ipipeif_try_format(ipipeif, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which); fse->min_width = format.width; fse->min_height = format.height; @@ -664,8 +663,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *c format.code = fse->code; format.width = -1; format.height = -1; - ipipeif_try_format(ipipeif, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which); fse->max_width = format.width; fse->max_height = format.height; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 02b6bdc0d771..80907b464412 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1489,7 +1489,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, format.format.code = fse->code; format.format.width = 1; format.format.height = 1; - format.which = V4L2_SUBDEV_FORMAT_TRY; + format.which = fse->which; isif_try_format(isif, cfg, &format); fse->min_width = format.format.width; fse->min_height = format.format.height; @@ -1501,7 +1501,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, format.format.code = fse->code; format.format.width = -1; format.format.height = -1; - format.which = V4L2_SUBDEV_FORMAT_TRY; + format.which = fse->which; isif_try_format(isif, cfg, &format); fse->max_width = format.format.width; fse->max_height = format.format.height; diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index acd9cb56f0f3..fee44dd45ccd 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1484,8 +1484,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - resizer_try_format(sd, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + resizer_try_format(sd, cfg, fse->pad, &format, fse->which); fse->min_width = format.width; fse->min_height = format.height; @@ -1495,8 +1494,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - resizer_try_format(sd, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + resizer_try_format(sd, cfg, fse->pad, &format, fse->which); fse->max_width = format.width; fse->max_height = format.height; diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index 2d5079deb631..d7ff7698a067 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -943,7 +943,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + csi2_try_format(csi2, cfg, fse->pad, &format, fse->which); fse->min_width = format.width; fse->min_height = format.height; @@ -953,7 +953,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + csi2_try_format(csi2, cfg, fse->pad, &format, fse->which); fse->max_width = format.width; fse->max_height = format.height; diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c index fc319822a33e..ff1d8cf3d284 100644 --- a/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/drivers/staging/media/omap4iss/iss_ipipe.c @@ -280,7 +280,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which); fse->min_width = format.width; fse->min_height = format.height; @@ -290,7 +290,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); + ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which); fse->max_width = format.width; fse->max_height = format.height; diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index b8e7277499d2..8000bd3bca34 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -492,8 +492,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - ipipeif_try_format(ipipeif, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which); fse->min_width = format.width; fse->min_height = format.height; @@ -503,8 +502,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - ipipeif_try_format(ipipeif, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which); fse->max_width = format.width; fse->max_height = format.height; diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index 075b876e8e68..ded9066c64d7 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -554,8 +554,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = 1; format.height = 1; - resizer_try_format(resizer, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + resizer_try_format(resizer, cfg, fse->pad, &format, fse->which); fse->min_width = format.width; fse->min_height = format.height; @@ -565,8 +564,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, format.code = fse->code; format.width = -1; format.height = -1; - resizer_try_format(resizer, cfg, fse->pad, &format, - V4L2_SUBDEV_FORMAT_TRY); + resizer_try_format(resizer, cfg, fse->pad, &format, fse->which); fse->max_width = format.width; fse->max_height = format.height; -- cgit v1.2.1 From 68feaa6b8bc537de1d02732fb1b74fe5433ceff1 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sun, 1 Feb 2015 15:12:56 -0300 Subject: [media] mn88472: Deletion of an unnecessary check before the function call "release_firmware" The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88472/mn88472.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index 6eebe564e557..ce14cb287594 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -299,8 +299,7 @@ static int mn88472_init(struct dvb_frontend *fe) return 0; err: - if (fw) - release_firmware(fw); + release_firmware(fw); dev_dbg(&client->dev, "failed=%d\n", ret); return ret; -- cgit v1.2.1 From bf104c238dc1c7172460853882a545141eaa8222 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sun, 1 Feb 2015 15:34:37 -0300 Subject: [media] mn88472: One function call less in mn88472_init() after error detection The release_firmware() function was called in three cases by the mn88472_init() function during error handling even if the passed variable "fw" contained still a null pointer. This implementation detail could be improved by the introduction of another jump label. Signed-off-by: Markus Elfring Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88472/mn88472.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index ce14cb287594..219a7d1db8d4 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -270,7 +270,7 @@ static int mn88472_init(struct dvb_frontend *fe) ret = regmap_write(dev->regmap[0], 0xf5, 0x03); if (ret) - goto err; + goto firmware_release; for (remaining = fw->size; remaining > 0; remaining -= (dev->i2c_wr_max - 1)) { @@ -283,13 +283,13 @@ static int mn88472_init(struct dvb_frontend *fe) if (ret) { dev_err(&client->dev, "firmware download failed=%d\n", ret); - goto err; + goto firmware_release; } } ret = regmap_write(dev->regmap[0], 0xf5, 0x00); if (ret) - goto err; + goto firmware_release; release_firmware(fw); fw = NULL; @@ -298,9 +298,9 @@ static int mn88472_init(struct dvb_frontend *fe) dev->warm = true; return 0; -err: +firmware_release: release_firmware(fw); - +err: dev_dbg(&client->dev, "failed=%d\n", ret); return ret; } -- cgit v1.2.1 From 9d9104fb9db90f7d806b1f0ba270c209b8d4fa25 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 11 Dec 2014 10:23:57 -0300 Subject: [media] staging: media: omap4iss: Cleanup media entities after unregistration The ipipeif, ipipe and resizer media entities are cleaned up before unregistering the media device, creating a race condition. Fix it by cleaning them up at cleanup time. Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss_ipipe.c | 6 +++--- drivers/staging/media/omap4iss/iss_ipipeif.c | 6 +++--- drivers/staging/media/omap4iss/iss_resizer.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c index ff1d8cf3d284..eaa82da30f50 100644 --- a/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/drivers/staging/media/omap4iss/iss_ipipe.c @@ -516,8 +516,6 @@ static int ipipe_init_entities(struct iss_ipipe_device *ipipe) void omap4iss_ipipe_unregister_entities(struct iss_ipipe_device *ipipe) { - media_entity_cleanup(&ipipe->subdev.entity); - v4l2_device_unregister_subdev(&ipipe->subdev); } @@ -566,5 +564,7 @@ int omap4iss_ipipe_init(struct iss_device *iss) */ void omap4iss_ipipe_cleanup(struct iss_device *iss) { - /* FIXME: are you sure there's nothing to do? */ + struct iss_ipipe_device *ipipe = &iss->ipipe; + + media_entity_cleanup(&ipipe->subdev.entity); } diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 8000bd3bca34..530ac8426b5b 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -771,8 +771,6 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) void omap4iss_ipipeif_unregister_entities(struct iss_ipipeif_device *ipipeif) { - media_entity_cleanup(&ipipeif->subdev.entity); - v4l2_device_unregister_subdev(&ipipeif->subdev); omap4iss_video_unregister(&ipipeif->video_out); } @@ -826,5 +824,7 @@ int omap4iss_ipipeif_init(struct iss_device *iss) */ void omap4iss_ipipeif_cleanup(struct iss_device *iss) { - /* FIXME: are you sure there's nothing to do? */ + struct iss_ipipeif_device *ipipeif = &iss->ipipeif; + + media_entity_cleanup(&ipipeif->subdev.entity); } diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index ded9066c64d7..5f69012c4deb 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -815,8 +815,6 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) void omap4iss_resizer_unregister_entities(struct iss_resizer_device *resizer) { - media_entity_cleanup(&resizer->subdev.entity); - v4l2_device_unregister_subdev(&resizer->subdev); omap4iss_video_unregister(&resizer->video_out); } @@ -870,5 +868,7 @@ int omap4iss_resizer_init(struct iss_device *iss) */ void omap4iss_resizer_cleanup(struct iss_device *iss) { - /* FIXME: are you sure there's nothing to do? */ + struct iss_resizer_device *resizer = &iss->resizer; + + media_entity_cleanup(&resizer->subdev.entity); } -- cgit v1.2.1 From ac0eb4809e88357b885c72b4e95def98235613c8 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 3 Mar 2015 08:08:42 -0300 Subject: [media] staging: media: omap4iss: video: Don't WARN() on unknown pixel formats When mapping from a V4L2 pixel format to a media bus format in the VIDIOC_TRY_FMT and VIDIOC_S_FMT handlers, the requested format may be unsupported by the driver. Return a hardcoded default format instead of WARN()ing in that case. Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss_video.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index 69550445a341..e949b6f179aa 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -171,14 +171,14 @@ static void iss_video_pix_to_mbus(const struct v4l2_pix_format *pix, mbus->width = pix->width; mbus->height = pix->height; - for (i = 0; i < ARRAY_SIZE(formats); ++i) { + /* Skip the last format in the loop so that it will be selected if no + * match is found. + */ + for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) { if (formats[i].pixelformat == pix->pixelformat) break; } - if (WARN_ON(i == ARRAY_SIZE(formats))) - return; - mbus->code = formats[i].code; mbus->colorspace = pix->colorspace; mbus->field = pix->field; -- cgit v1.2.1 From ba6d6d8a06c323782badf8cbead6e4ec1c742235 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Sun, 15 Mar 2015 19:57:50 -0300 Subject: [media] mn88472: implement lock for all delivery systems The increase of the lock timeout is needed for dvb-t2. Signed-off-by: Benjamin Larsson Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88472/mn88472.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index 219a7d1db8d4..6f0cac44d273 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -19,7 +19,7 @@ static int mn88472_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings *s) { - s->min_delay_ms = 400; + s->min_delay_ms = 800; return 0; } @@ -201,6 +201,7 @@ static int mn88472_read_status(struct dvb_frontend *fe, fe_status_t *status) struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret; unsigned int utmp; + int lock = 0; *status = 0; @@ -211,21 +212,36 @@ static int mn88472_read_status(struct dvb_frontend *fe, fe_status_t *status) switch (c->delivery_system) { case SYS_DVBT: + ret = regmap_read(dev->regmap[0], 0x7F, &utmp); + if (ret) + goto err; + if ((utmp & 0xF) >= 0x09) + lock = 1; + break; case SYS_DVBT2: - /* FIXME: implement me */ - utmp = 0x08; /* DVB-C lock value */ + ret = regmap_read(dev->regmap[2], 0x92, &utmp); + if (ret) + goto err; + if ((utmp & 0xF) >= 0x07) + *status |= FE_HAS_SIGNAL; + if ((utmp & 0xF) >= 0x0a) + *status |= FE_HAS_CARRIER; + if ((utmp & 0xF) >= 0x0d) + *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; break; case SYS_DVBC_ANNEX_A: ret = regmap_read(dev->regmap[1], 0x84, &utmp); if (ret) goto err; + if ((utmp & 0xF) >= 0x08) + lock = 1; break; default: ret = -EINVAL; goto err; } - if (utmp == 0x08) + if (lock) *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; -- cgit v1.2.1 From 307e95c92257fe2602b457ab6df56d9ef9a7444e Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Sun, 15 Mar 2015 19:57:51 -0300 Subject: [media] mn88472: implement firmware parity check Signed-off-by: Benjamin Larsson Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88472/mn88472.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index 6f0cac44d273..85ef4f694c8b 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -258,6 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe) int ret, len, remaining; const struct firmware *fw = NULL; u8 *fw_file = MN88472_FIRMWARE; + unsigned int csum; dev_dbg(&client->dev, "\n"); @@ -303,6 +304,20 @@ static int mn88472_init(struct dvb_frontend *fe) } } + /* parity check of firmware */ + ret = regmap_read(dev->regmap[0], 0xf8, &csum); + if (ret) { + dev_err(&client->dev, + "parity reg read failed=%d\n", ret); + goto err; + } + if (csum & 0x10) { + dev_err(&client->dev, + "firmware parity check failed=0x%x\n", csum); + goto err; + } + dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum); + ret = regmap_write(dev->regmap[0], 0xf5, 0x00); if (ret) goto firmware_release; -- cgit v1.2.1 From 0f21ac7f92e8a014a3c653337fbae7af4c240c3a Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Sun, 15 Mar 2015 19:57:52 -0300 Subject: [media] mn88473: implement firmware parity check Signed-off-by: Benjamin Larsson Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88473/mn88473.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c index 84bd4fa3c627..607ce4d3b12f 100644 --- a/drivers/staging/media/mn88473/mn88473.c +++ b/drivers/staging/media/mn88473/mn88473.c @@ -192,6 +192,7 @@ static int mn88473_init(struct dvb_frontend *fe) int ret, len, remaining; const struct firmware *fw = NULL; u8 *fw_file = MN88473_FIRMWARE; + unsigned int tmp; dev_dbg(&client->dev, "\n"); @@ -227,6 +228,20 @@ static int mn88473_init(struct dvb_frontend *fe) } } + /* parity check of firmware */ + ret = regmap_read(dev->regmap[0], 0xf8, &tmp); + if (ret) { + dev_err(&client->dev, + "parity reg read failed=%d\n", ret); + goto err; + } + if (tmp & 0x10) { + dev_err(&client->dev, + "firmware parity check failed=0x%x\n", tmp); + goto err; + } + dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp); + ret = regmap_write(dev->regmap[0], 0xf5, 0x00); if (ret) goto err; -- cgit v1.2.1 From 567627bfb2b5837315fe467e52c1bbca634acc00 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Sun, 15 Mar 2015 19:57:53 -0300 Subject: [media] mn88473: check if firmware is already running before loading it Signed-off-by: Benjamin Larsson Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88473/mn88473.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c index 607ce4d3b12f..a23e59e1537e 100644 --- a/drivers/staging/media/mn88473/mn88473.c +++ b/drivers/staging/media/mn88473/mn88473.c @@ -196,8 +196,19 @@ static int mn88473_init(struct dvb_frontend *fe) dev_dbg(&client->dev, "\n"); - if (dev->warm) + /* set cold state by default */ + dev->warm = false; + + /* check if firmware is already running */ + ret = regmap_read(dev->regmap[0], 0xf5, &tmp); + if (ret) + goto err; + + if (!(tmp & 0x1)) { + dev_info(&client->dev, "firmware already running\n"); + dev->warm = true; return 0; + } /* request the firmware, this will block and timeout */ ret = request_firmware(&fw, fw_file, &client->dev); -- cgit v1.2.1 From 4752eb273133778816e7affe6c8381712f363c50 Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Sun, 15 Mar 2015 19:57:54 -0300 Subject: [media] mn88472: check if firmware is already running before loading it Signed-off-by: Benjamin Larsson Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88472/mn88472.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index 85ef4f694c8b..bfb3e447773a 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -258,7 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe) int ret, len, remaining; const struct firmware *fw = NULL; u8 *fw_file = MN88472_FIRMWARE; - unsigned int csum; + unsigned int tmp; dev_dbg(&client->dev, "\n"); @@ -274,6 +274,17 @@ static int mn88472_init(struct dvb_frontend *fe) if (ret) goto err; + /* check if firmware is already running */ + ret = regmap_read(dev->regmap[0], 0xf5, &tmp); + if (ret) + goto err; + + if (!(tmp & 0x1)) { + dev_info(&client->dev, "firmware already running\n"); + dev->warm = true; + return 0; + } + /* request the firmware, this will block and timeout */ ret = request_firmware(&fw, fw_file, &client->dev); if (ret) { @@ -305,18 +316,18 @@ static int mn88472_init(struct dvb_frontend *fe) } /* parity check of firmware */ - ret = regmap_read(dev->regmap[0], 0xf8, &csum); + ret = regmap_read(dev->regmap[0], 0xf8, &tmp); if (ret) { dev_err(&client->dev, "parity reg read failed=%d\n", ret); goto err; } - if (csum & 0x10) { + if (tmp & 0x10) { dev_err(&client->dev, - "firmware parity check failed=0x%x\n", csum); + "firmware parity check failed=0x%x\n", tmp); goto err; } - dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum); + dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp); ret = regmap_write(dev->regmap[0], 0xf5, 0x00); if (ret) -- cgit v1.2.1 From 8459e41da53b48e9b5f92312f27e07a67ea6b27a Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Mon, 16 Mar 2015 18:56:21 -0300 Subject: [media] mn88473: define symbol rate limits w_scan complains about missing symbol rate limits: This dvb driver is *buggy*: the symbol rate limits are undefined - please report to linuxtv.org Lets add some reasonable limits in order to keep w_scan happy :) Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88473/mn88473.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c index a23e59e1537e..f98b982398bc 100644 --- a/drivers/staging/media/mn88473/mn88473.c +++ b/drivers/staging/media/mn88473/mn88473.c @@ -296,6 +296,8 @@ static struct dvb_frontend_ops mn88473_ops = { .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_AC}, .info = { .name = "Panasonic MN88473", + .symbol_rate_min = 1000000, + .symbol_rate_max = 7200000, .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | -- cgit v1.2.1 From d73ab406137fb137f1ac56ed43cfb8a151179940 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Mon, 16 Mar 2015 19:01:53 -0300 Subject: [media] mn88472: define symbol rate limits w_scan complains about missing symbol rate limits: This dvb driver is *buggy*: the symbol rate limits are undefined - please report to linuxtv.org Lets add some reasonable limits in order to keep w_scan happy :) Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88472/mn88472.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index bfb3e447773a..44edcf652223 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -377,6 +377,8 @@ static struct dvb_frontend_ops mn88472_ops = { .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A}, .info = { .name = "Panasonic MN88472", + .symbol_rate_min = 1000000, + .symbol_rate_max = 7200000, .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | -- cgit v1.2.1 From 0aa83bb1814e64bfc744abb6bae85e264edee4ef Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Sat, 21 Mar 2015 07:18:07 -0300 Subject: [media] mn88473: implement lock for all delivery systems Add capability to check if digital TV has lock for all delivery systems. Signed-off-by: Benjamin Larsson Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88473/mn88473.c | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c index f98b982398bc..e909d62a086a 100644 --- a/drivers/staging/media/mn88473/mn88473.c +++ b/drivers/staging/media/mn88473/mn88473.c @@ -167,7 +167,10 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status) { struct i2c_client *client = fe->demodulator_priv; struct mn88473_dev *dev = i2c_get_clientdata(client); + struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret; + unsigned int utmp; + int lock = 0; *status = 0; @@ -176,8 +179,51 @@ static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status) goto err; } - *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | - FE_HAS_SYNC | FE_HAS_LOCK; + switch (c->delivery_system) { + case SYS_DVBT: + ret = regmap_read(dev->regmap[0], 0x62, &utmp); + if (ret) + goto err; + if (!(utmp & 0xA0)) { + if ((utmp & 0xF) >= 0x03) + *status |= FE_HAS_SIGNAL; + if ((utmp & 0xF) >= 0x09) + lock = 1; + } + break; + case SYS_DVBT2: + ret = regmap_read(dev->regmap[2], 0x8B, &utmp); + if (ret) + goto err; + if (!(utmp & 0x40)) { + if ((utmp & 0xF) >= 0x07) + *status |= FE_HAS_SIGNAL; + if ((utmp & 0xF) >= 0x0a) + *status |= FE_HAS_CARRIER; + if ((utmp & 0xF) >= 0x0d) + *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; + } + break; + case SYS_DVBC_ANNEX_A: + ret = regmap_read(dev->regmap[1], 0x85, &utmp); + if (ret) + goto err; + if (!(utmp & 0x40)) { + ret = regmap_read(dev->regmap[1], 0x89, &utmp); + if (ret) + goto err; + if (utmp & 0x01) + lock = 1; + } + break; + default: + ret = -EINVAL; + goto err; + } + + if (lock) + *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | + FE_HAS_SYNC | FE_HAS_LOCK; return 0; err: -- cgit v1.2.1 From 54ad7b9d427e62f21138aacf92f8d7585344f6df Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 9 Mar 2015 13:33:58 -0300 Subject: [media] radio-bcm2048: embed video_device Embed the video_device struct to simplify the error handling and in order to (eventually) get rid of video_device_alloc/release. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/bcm2048/radio-bcm2048.c | 33 ++++++++------------------- 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index 297ceaa89b7c..bd50fb204019 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -279,7 +279,7 @@ struct region_info { struct bcm2048_device { struct i2c_client *client; - struct video_device *videodev; + struct video_device videodev; struct work_struct work; struct completion compl; struct mutex mutex; @@ -2583,7 +2583,7 @@ static struct v4l2_ioctl_ops bcm2048_ioctl_ops = { static struct video_device bcm2048_viddev_template = { .fops = &bcm2048_fops, .name = BCM2048_DRIVER_NAME, - .release = video_device_release, + .release = video_device_release_empty, .ioctl_ops = &bcm2048_ioctl_ops, }; @@ -2602,13 +2602,6 @@ static int bcm2048_i2c_driver_probe(struct i2c_client *client, goto exit; } - bdev->videodev = video_device_alloc(); - if (!bdev->videodev) { - dev_dbg(&client->dev, "Failed to alloc video device.\n"); - err = -ENOMEM; - goto free_bdev; - } - bdev->client = client; i2c_set_clientdata(client, bdev); mutex_init(&bdev->mutex); @@ -2621,16 +2614,16 @@ static int bcm2048_i2c_driver_probe(struct i2c_client *client, client->name, bdev); if (err < 0) { dev_err(&client->dev, "Could not request IRQ\n"); - goto free_vdev; + goto free_bdev; } dev_dbg(&client->dev, "IRQ requested.\n"); } else { dev_dbg(&client->dev, "IRQ not configured. Using timeouts.\n"); } - *bdev->videodev = bcm2048_viddev_template; - video_set_drvdata(bdev->videodev, bdev); - if (video_register_device(bdev->videodev, VFL_TYPE_RADIO, radio_nr)) { + bdev->videodev = bcm2048_viddev_template; + video_set_drvdata(&bdev->videodev, bdev); + if (video_register_device(&bdev->videodev, VFL_TYPE_RADIO, radio_nr)) { dev_dbg(&client->dev, "Could not register video device.\n"); err = -EIO; goto free_irq; @@ -2653,18 +2646,13 @@ static int bcm2048_i2c_driver_probe(struct i2c_client *client, free_sysfs: bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs)); free_registration: - video_unregister_device(bdev->videodev); - /* video_unregister_device frees bdev->videodev */ - bdev->videodev = NULL; + video_unregister_device(&bdev->videodev); skip_release = 1; free_irq: if (client->irq) free_irq(client->irq, bdev); -free_vdev: - if (!skip_release) - video_device_release(bdev->videodev); - i2c_set_clientdata(client, NULL); free_bdev: + i2c_set_clientdata(client, NULL); kfree(bdev); exit: return err; @@ -2673,16 +2661,13 @@ exit: static int __exit bcm2048_i2c_driver_remove(struct i2c_client *client) { struct bcm2048_device *bdev = i2c_get_clientdata(client); - struct video_device *vd; if (!client->adapter) return -ENODEV; if (bdev) { - vd = bdev->videodev; - bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs)); - video_unregister_device(vd); + video_unregister_device(&bdev->videodev); if (bdev->power_state) bcm2048_set_power_state(bdev, BCM2048_POWER_OFF); -- cgit v1.2.1 From f91fccde35cd41b085756b134d94b6f87ed1c94e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 9 Mar 2015 13:33:59 -0300 Subject: [media] dt3155v4l: embed video_device Embed the video_device struct to simplify the error handling and in order to (eventually) get rid of video_device_alloc/release. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/dt3155v4l/dt3155v4l.c | 30 ++++++++++------------------- drivers/staging/media/dt3155v4l/dt3155v4l.h | 4 ++-- 2 files changed, 12 insertions(+), 22 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c index e60a53e744c4..52a8ffe560b1 100644 --- a/drivers/staging/media/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c @@ -244,7 +244,7 @@ dt3155_wait_prepare(struct vb2_queue *q) { struct dt3155_priv *pd = vb2_get_drv_priv(q); - mutex_unlock(pd->vdev->lock); + mutex_unlock(pd->vdev.lock); } static void @@ -252,7 +252,7 @@ dt3155_wait_finish(struct vb2_queue *q) { struct dt3155_priv *pd = vb2_get_drv_priv(q); - mutex_lock(pd->vdev->lock); + mutex_lock(pd->vdev.lock); } static int @@ -824,7 +824,7 @@ static struct video_device dt3155_vdev = { .fops = &dt3155_fops, .ioctl_ops = &dt3155_ioctl_ops, .minor = -1, - .release = video_device_release, + .release = video_device_release_empty, .tvnorms = DT3155_CURRENT_NORM, }; @@ -904,24 +904,21 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL); if (!pd) return -ENOMEM; - pd->vdev = video_device_alloc(); - if (!pd->vdev) - return -ENOMEM; - *pd->vdev = dt3155_vdev; + pd->vdev = dt3155_vdev; pci_set_drvdata(pdev, pd); /* for use in dt3155_remove() */ - video_set_drvdata(pd->vdev, pd); /* for use in video_fops */ + video_set_drvdata(&pd->vdev, pd); /* for use in video_fops */ pd->users = 0; pd->pdev = pdev; INIT_LIST_HEAD(&pd->dmaq); mutex_init(&pd->mux); - pd->vdev->lock = &pd->mux; /* for locking v4l2_file_operations */ + pd->vdev.lock = &pd->mux; /* for locking v4l2_file_operations */ spin_lock_init(&pd->lock); pd->csr2 = csr2_init; pd->config = config_init; err = pci_enable_device(pdev); if (err) - goto err_enable_dev; + return err; err = pci_request_region(pdev, 0, pci_name(pdev)); if (err) goto err_req_region; @@ -933,13 +930,13 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = dt3155_init_board(pdev); if (err) goto err_init_board; - err = video_register_device(pd->vdev, VFL_TYPE_GRABBER, -1); + err = video_register_device(&pd->vdev, VFL_TYPE_GRABBER, -1); if (err) goto err_init_board; if (dt3155_alloc_coherent(&pdev->dev, DT3155_CHUNK_SIZE, DMA_MEMORY_MAP)) dev_info(&pdev->dev, "preallocated 8 buffers\n"); - dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev->minor); + dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev.minor); return 0; /* success */ err_init_board: @@ -948,9 +945,6 @@ err_pci_iomap: pci_release_region(pdev, 0); err_req_region: pci_disable_device(pdev); -err_enable_dev: - video_device_release(pd->vdev); - return err; } @@ -960,14 +954,10 @@ dt3155_remove(struct pci_dev *pdev) struct dt3155_priv *pd = pci_get_drvdata(pdev); dt3155_free_coherent(&pdev->dev); - video_unregister_device(pd->vdev); + video_unregister_device(&pd->vdev); pci_iounmap(pdev, pd->regs); pci_release_region(pdev, 0); pci_disable_device(pdev); - /* - * video_device_release() is invoked automatically - * see: struct video_device dt3155_vdev - */ } static const struct pci_device_id pci_ids[] = { diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h b/drivers/staging/media/dt3155v4l/dt3155v4l.h index 2e4f89d402e4..96f01a0c7581 100644 --- a/drivers/staging/media/dt3155v4l/dt3155v4l.h +++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h @@ -178,7 +178,7 @@ struct dt3155_stats { /** * struct dt3155_priv - private data structure * - * @vdev: pointer to video_device structure + * @vdev: video_device structure * @pdev: pointer to pci_dev structure * @q pointer to vb2_queue structure * @curr_buf: pointer to curren buffer @@ -193,7 +193,7 @@ struct dt3155_stats { * @config: local copy of config register */ struct dt3155_priv { - struct video_device *vdev; + struct video_device vdev; struct pci_dev *pdev; struct vb2_queue *q; struct vb2_buffer *curr_buf; -- cgit v1.2.1 From 021cd2d21b5d68d6e7c1edb468e990e1c0caf6fb Mon Sep 17 00:00:00 2001 From: Benjamin Larsson Date: Fri, 5 Dec 2014 21:25:33 -0300 Subject: [media] mn88472: add ts mode and ts clock to driver Signed-off-by: Benjamin Larsson Reviewed-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/mn88472/mn88472.c | 30 ++++++++++++++++++++++++++-- drivers/staging/media/mn88472/mn88472_priv.h | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index 44edcf652223..ed379abcacc0 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -178,8 +178,32 @@ static int mn88472_set_frontend(struct dvb_frontend *fe) ret = regmap_write(dev->regmap[0], 0x46, 0x00); ret = regmap_write(dev->regmap[0], 0xae, 0x00); - ret = regmap_write(dev->regmap[2], 0x08, 0x1d); - ret = regmap_write(dev->regmap[0], 0xd9, 0xe3); + + switch (dev->ts_mode) { + case SERIAL_TS_MODE: + ret = regmap_write(dev->regmap[2], 0x08, 0x1d); + break; + case PARALLEL_TS_MODE: + ret = regmap_write(dev->regmap[2], 0x08, 0x00); + break; + default: + dev_dbg(&client->dev, "ts_mode error: %d\n", dev->ts_mode); + ret = -EINVAL; + goto err; + } + + switch (dev->ts_clock) { + case VARIABLE_TS_CLOCK: + ret = regmap_write(dev->regmap[0], 0xd9, 0xe3); + break; + case FIXED_TS_CLOCK: + ret = regmap_write(dev->regmap[0], 0xd9, 0xe1); + break; + default: + dev_dbg(&client->dev, "ts_clock error: %d\n", dev->ts_clock); + ret = -EINVAL; + goto err; + } /* Reset demod */ ret = regmap_write(dev->regmap[2], 0xf8, 0x9f); @@ -439,6 +463,8 @@ static int mn88472_probe(struct i2c_client *client, dev->i2c_wr_max = config->i2c_wr_max; dev->xtal = config->xtal; + dev->ts_mode = config->ts_mode; + dev->ts_clock = config->ts_clock; dev->client[0] = client; dev->regmap[0] = regmap_init_i2c(dev->client[0], ®map_config); if (IS_ERR(dev->regmap[0])) { diff --git a/drivers/staging/media/mn88472/mn88472_priv.h b/drivers/staging/media/mn88472/mn88472_priv.h index b12b731e2d4e..9ba8c8b3823e 100644 --- a/drivers/staging/media/mn88472/mn88472_priv.h +++ b/drivers/staging/media/mn88472/mn88472_priv.h @@ -32,6 +32,8 @@ struct mn88472_dev { fe_delivery_system_t delivery_system; bool warm; /* FW running */ u32 xtal; + int ts_mode; + int ts_clock; }; #endif -- cgit v1.2.1