From patchwork Thu Jan 29 16:19:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Towle X-Patchwork-Id: 28100 X-Patchwork-Delegate: g.liakhovetski@gmx.de Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1YGrpQ-0003CA-Q5; Thu, 29 Jan 2015 17:20:24 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-5) with esmtp id 1YGrpO-0005SC-6n; Thu, 29 Jan 2015 17:20:23 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755222AbbA2QUN (ORCPT + 1 other); Thu, 29 Jan 2015 11:20:13 -0500 Received: from 82-70-136-246.dsl.in-addr.zen.co.uk ([82.70.136.246]:55516 "EHLO xk120" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753065AbbA2QTw (ORCPT ); Thu, 29 Jan 2015 11:19:52 -0500 Received: from william by xk120 with local (Exim 4.80) (envelope-from ) id 1YGrot-0007Wn-6s; Thu, 29 Jan 2015 16:19:51 +0000 From: William Towle To: linux-kernel@lists.codethink.co.uk, linux-media@vger.kernel.org, Guennadi Liakhovetski , Sergei Shtylyov , Hans Verkuil Subject: [PATCH 7/8] WmT: rcar_vin new ADV7612 support Date: Thu, 29 Jan 2015 16:19:47 +0000 Message-Id: <1422548388-28861-8-git-send-email-william.towle@codethink.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1422548388-28861-1-git-send-email-william.towle@codethink.co.uk> References: <1422548388-28861-1-git-send-email-william.towle@codethink.co.uk> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.1.29.161217 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_6000_6999 0, BODY_SIZE_7000_LESS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_TO_X5 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Add 'struct media_pad pad' member and suitable glue code, so that soc_camera/rcar_vin can become agnostic to whether an old or new- style driver (wrt pad API use) can sit underneath This version has been reworked to include appropriate constant and datatype names for kernel v3.18 --- ** this version for kernel 3.18.x+ (v4l2 constant names) ** ** now including: ** | WmT: assume max resolution at init | | Make rcar_vin agnostic to the driver beneath having a smaller | resolution as its default size. Previously, the logic for calculating | cropping region size -which depends on going from larger to smaller | values- would have been confused by this. --- drivers/media/platform/soc_camera/rcar_vin.c | 112 +++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index e4f60d3..046fcc1 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -932,9 +932,27 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, u32 code; const struct soc_mbus_pixelfmt *fmt; - ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); - if (ret < 0) - return 0; + // subdev_has_op -> enum_mbus_code vs enum_mbus_fmt + if (v4l2_subdev_has_op(sd, pad, enum_mbus_code)) { + struct v4l2_subdev_mbus_code_enum c; + + c.index = idx; + + ret = v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, &c); + if (ret < 0) + return 0; + +#if 1 /* ideal */ + code = c.code; +#else /* Ian HACK - required with full(er) formats table */ + code = MEDIA_BUS_FMT_RGB888_1X24; //HACK +#endif + } + else { + ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code); + if (ret < 0) + return 0; + } fmt = soc_mbus_get_fmtdesc(code); if (!fmt) { @@ -948,11 +966,28 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, if (!icd->host_priv) { struct v4l2_mbus_framefmt mf; + struct v4l2_subdev_format sd_format; struct v4l2_rect rect; struct device *dev = icd->parent; int shift; - ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); + // subdev_has_op -> get_fmt vs g_mbus_fmt + if (v4l2_subdev_has_op(sd, pad, get_fmt)) { + struct media_pad *remote_pad; + + remote_pad= media_entity_remote_pad(&icd->vdev->entity.pads[0]); + sd_format.pad= remote_pad->index; + sd_format.which=V4L2_SUBDEV_FORMAT_ACTIVE; + + ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, + &sd_format); + mf= sd_format.format; + mf.width= VIN_MAX_WIDTH; + mf.height= VIN_MAX_HEIGHT; + } + else { + ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); + } if (ret < 0) return ret; @@ -979,10 +1014,18 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, mf.width = 1280 >> shift; mf.height = 960 >> shift; - ret = v4l2_device_call_until_err(sd->v4l2_dev, - soc_camera_grp_id(icd), - video, s_mbus_fmt, - &mf); + // subdev_has_op -> set_fmt vs s_mbus_fmt + if (v4l2_subdev_has_op(sd, pad, set_fmt)) { + ret = v4l2_device_call_until_err(sd->v4l2_dev, + soc_camera_grp_id(icd), + pad, set_fmt, NULL, + &sd_format); + } else { + ret = v4l2_device_call_until_err(sd->v4l2_dev, + soc_camera_grp_id(icd), + video, s_mbus_fmt, + &mf); + } if (ret < 0) return ret; } @@ -1099,7 +1142,22 @@ static int rcar_vin_set_crop(struct soc_camera_device *icd, /* On success cam_crop contains current camera crop */ /* Retrieve camera output window */ - ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); + // subdev_has_op -> get_fmt vs g_mbus_fmt + if (v4l2_subdev_has_op(sd, pad, get_fmt)) + { + struct v4l2_subdev_format sd_format; + struct media_pad *remote_pad; + + remote_pad= media_entity_remote_pad(&icd->vdev->entity.pads[0]); + sd_format.pad= remote_pad->index; + sd_format.which= V4L2_SUBDEV_FORMAT_ACTIVE; + ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &sd_format); + + mf.width= sd_format.format.width; + mf.height= sd_format.format.height; + } else { + ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); + } if (ret < 0) return ret; @@ -1314,8 +1372,22 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, mf.code = xlate->code; mf.colorspace = pix->colorspace; - ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd), + // subdev_has_op -> get_fmt vs try_mbus_fmt + if (v4l2_subdev_has_op(sd, pad, get_fmt)) { + struct v4l2_subdev_format sd_format; + struct media_pad *remote_pad; + + remote_pad= media_entity_remote_pad( + &icd->vdev->entity.pads[0]); + sd_format.pad= remote_pad->index; + sd_format.format= mf; + ret= v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd), + pad, get_fmt, NULL, &sd_format); + mf= sd_format.format; + } else { + ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd), video, try_mbus_fmt, &mf); + } if (ret < 0) return ret; @@ -1335,10 +1407,28 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, */ mf.width = VIN_MAX_WIDTH; mf.height = VIN_MAX_HEIGHT; - ret = v4l2_device_call_until_err(sd->v4l2_dev, + // subdev_has_op -> get_fmt vs try_mbus_fmt + if (v4l2_subdev_has_op(sd, pad, get_fmt)) { + struct v4l2_subdev_format sd_format; + struct media_pad *remote_pad; + + remote_pad= media_entity_remote_pad( + &icd->vdev->entity.pads[0]); + sd_format.pad = remote_pad->index; + sd_format.which= V4L2_SUBDEV_FORMAT_TRY; + sd_format.format= mf; + ret = v4l2_device_call_until_err(sd->v4l2_dev, + soc_camera_grp_id(icd), + pad, get_fmt, + NULL, &sd_format); + mf= sd_format.format; + } else { + ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd), video, try_mbus_fmt, &mf); + } + if (ret < 0) { dev_err(icd->parent, "client try_fmt() = %d\n", ret);