From patchwork Fri Jan 25 07:01:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 2041511 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by patchwork2.kernel.org (Postfix) with ESMTP id 8AF33DF223 for ; Fri, 25 Jan 2013 07:07:24 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0P73VLu003007; Fri, 25 Jan 2013 01:03:31 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0P73VpS013926; Fri, 25 Jan 2013 01:03:31 -0600 Received: from dlelxv24.itg.ti.com (172.17.1.199) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Fri, 25 Jan 2013 01:03:31 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0P73VnN009632; Fri, 25 Jan 2013 01:03:31 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 8F88E80626; Fri, 25 Jan 2013 01:03:30 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id F3E6280630 for ; Fri, 25 Jan 2013 01:01:55 -0600 (CST) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r0P71tNo013579 for ; Fri, 25 Jan 2013 01:01:55 -0600 (CST) Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0P71ta1016972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 Jan 2013 01:01:55 -0600 Received: from [216.82.250.99:5395] by server-10.bemta-12.messagelabs.com id AF/79-00346-3ED22015; Fri, 25 Jan 2013 07:01:55 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-5.tower-126.messagelabs.com!1359097313!1773639!1 X-Originating-IP: [209.85.210.50] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, ML_RADAR_SPEW_LINKS_14,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.7; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21338 invoked from network); 25 Jan 2013 07:01:54 -0000 Received: from mail-da0-f50.google.com (HELO mail-da0-f50.google.com) (209.85.210.50) by server-5.tower-126.messagelabs.com with RC4-SHA encrypted SMTP; 25 Jan 2013 07:01:54 -0000 Received: by mail-da0-f50.google.com with SMTP id h15so31369dan.9 for ; Thu, 24 Jan 2013 23:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=izDDhhcrNI9Dyt/DPhlsR8kzdnEyo64gX75f/Z4XHKg=; b=AmJE6wJC7VxSicPi+vz1kNOtqvJTqlmifdWfMapCoya8mOqPEp65DyMlvIU42xp64N F6ndW+bjwH6VG0he/5GzFGoI7W7/CG1dS9LeWjAkn7bOuI5coQ0V0cJTMZN6GrjWqf4/ yrfHUZNID0dLmWvR/M+81mlEsXzGSuWoZplS8gzXdedvCy644rX60iTB3FUR1TWKwXNA 71TW3PK5UVq/RrnAS/WPfQ92qx2OfsBho2+gGmHMTMR0Ej0dvf3DELHb019/4PTCu7/0 j0w+o120KNgca8vd9G1tfCH9nQJo2EOGrJsgdtzM+Y+DYIwSw9ATscpiaN9KoHK+IGJA 6qfg== X-Received: by 10.68.219.164 with SMTP id pp4mr11877306pbc.72.1359097313160; Thu, 24 Jan 2013 23:01:53 -0800 (PST) Received: from localhost.localdomain ([122.166.13.141]) by mx.google.com with ESMTPS id l5sm313253pax.10.2013.01.24.23.01.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 23:01:52 -0800 (PST) From: Prabhakar Lad To: LMML Subject: [PATCH 2/2] media: tvp7002: enable TVP7002 decoder for media controller based usage Date: Fri, 25 Jan 2013 12:31:08 +0530 Message-ID: <1359097268-22779-3-git-send-email-prabhakar.lad@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1359097268-22779-1-git-send-email-prabhakar.lad@ti.com> References: <1359097268-22779-1-git-send-email-prabhakar.lad@ti.com> CC: DLOS , Mauro Carvalho Chehab , LKML , Hans Verkuil X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: Manjunath Hadli add pad operations support for g_mbus_fmt, enum_mbus_code, set_pad_format, get_pad_format and media_entity_init. The device supports 1 output pad and no input pads. Signed-off-by: Manjunath Hadli Signed-off-by: Lad, Prabhakar --- drivers/media/i2c/tvp7002.c | 132 +++++++++++++++++++++++++++++++++++++++++- include/media/tvp7002.h | 2 + 2 files changed, 130 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index fb6a5b5..312651e 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -41,9 +41,6 @@ MODULE_DESCRIPTION("TI TVP7002 Video and Graphics Digitizer driver"); MODULE_AUTHOR("Santiago Nunez-Corrales "); MODULE_LICENSE("GPL"); -/* Module Name */ -#define TVP7002_MODULE_NAME "tvp7002" - /* I2C retry attempts */ #define I2C_RETRY_COUNT (5) @@ -432,6 +429,9 @@ struct tvp7002 { int streaming; const struct tvp7002_preset_definition *current_preset; + /* mc related members */ + struct media_pad pad; + struct v4l2_mbus_framefmt format; }; /* @@ -967,6 +967,109 @@ static const struct v4l2_ctrl_ops tvp7002_ctrl_ops = { .s_ctrl = tvp7002_s_ctrl, }; +/* + * tvp7002_enum_mbus_code() - Enum supported digital video format on pad + * @sd: pointer to standard V4L2 sub-device structure + * @fh: file handle for the subdev + * @code: pointer to subdev enum mbus code struct + * + * Enumerate supported digital video formats for pad. + */ +static int +tvp7002_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, + struct v4l2_subdev_mbus_code_enum *code) +{ + /* Check pad index is valid */ + if (code->pad != 0) + return -EINVAL; + + /* Check requested format index is within range */ + if (code->index != 0) + return -EINVAL; + + code->code = V4L2_MBUS_FMT_YUYV10_1X20; + + return 0; +} + +/* + * tvp7002_set_pad_format() - set video format on pad + * @sd: pointer to standard V4L2 sub-device structure + * @fh: file handle for the subdev + * @fmt: pointer to subdev format struct + * + * set video format for pad. + */ +static int +tvp7002_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, + struct v4l2_subdev_format *fmt) +{ + struct tvp7002 *device = to_tvp7002(sd); + struct v4l2_dv_enum_preset e_preset; + int error; + + /* Check pad index is valid */ + if (fmt->pad != 0) + return -EINVAL; + + /* Calculate height and width based on current standard */ + error = v4l_fill_dv_preset_info(device->current_preset->preset, + &e_preset); + if (error) + return error; + + fmt->format.code = V4L2_MBUS_FMT_YUYV10_1X20; + fmt->format.width = e_preset.width; + fmt->format.height = e_preset.height; + fmt->format.field = device->current_preset->scanmode; + fmt->format.colorspace = device->current_preset->color_space; + /* store for future use */ + device->format = fmt->format; + + return 0; +} + +/* + * tvp7002_get_pad_format() - get video format on pad + * @sd: pointer to standard V4L2 sub-device structure + * @fh: file handle for the subdev + * @fmt: pointer to subdev format struct + * + * get video format for pad. + */ +static int +tvp7002_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, + struct v4l2_subdev_format *fmt) +{ + struct tvp7002 *device = to_tvp7002(sd); + struct v4l2_dv_enum_preset e_preset; + __u32 which = fmt->which; + int error; + + /* Check pad index is valid */ + if (fmt->pad != 0) + return -EINVAL; + + if (which == V4L2_SUBDEV_FORMAT_ACTIVE) { + fmt->format = device->format; + return 0; + } + + /* Calculate height and width based on current standard */ + error = v4l_fill_dv_preset_info(device->current_preset->preset, + &e_preset); + if (error) + return error; + + fmt->format.code = V4L2_MBUS_FMT_YUYV10_1X20; + fmt->format.width = e_preset.width; + fmt->format.height = e_preset.height; + fmt->format.field = device->current_preset->scanmode; + fmt->format.colorspace = device->current_preset->color_space; + + return 0; +} + /* V4L2 core operation handlers */ static const struct v4l2_subdev_core_ops tvp7002_core_ops = { .g_chip_ident = tvp7002_g_chip_ident, @@ -1000,10 +1103,18 @@ static const struct v4l2_subdev_video_ops tvp7002_video_ops = { .enum_mbus_fmt = tvp7002_enum_mbus_fmt, }; +/* media pad related operation handlers */ +static const struct v4l2_subdev_pad_ops tvp7002_pad_ops = { + .enum_mbus_code = tvp7002_enum_mbus_code, + .get_fmt = tvp7002_get_pad_format, + .set_fmt = tvp7002_set_pad_format, +}; + /* V4L2 top level operation handlers */ static const struct v4l2_subdev_ops tvp7002_ops = { .core = &tvp7002_core_ops, .video = &tvp7002_video_ops, + .pad = &tvp7002_pad_ops, }; /* @@ -1047,6 +1158,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) /* Tell v4l2 the device is ready */ v4l2_i2c_subdev_init(sd, c, &tvp7002_ops); + strlcpy(sd->name, TVP7002_MODULE_NAME, sizeof(sd->name)); v4l_info(c, "tvp7002 found @ 0x%02x (%s)\n", c->addr, c->adapter->name); @@ -1096,6 +1208,16 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) } v4l2_ctrl_handler_setup(&device->hdl); +#if defined(CONFIG_MEDIA_CONTROLLER) + device->pad.flags = MEDIA_PAD_FL_SOURCE; + device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + device->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + + error = media_entity_init(&device->sd.entity, 1, &device->pad, 0); + if (error < 0) + goto found_error; +#endif + found_error: if (error < 0) kfree(device); @@ -1117,7 +1239,9 @@ static int tvp7002_remove(struct i2c_client *c) v4l2_dbg(1, debug, sd, "Removing tvp7002 adapter" "on address 0x%x\n", c->addr); - +#if defined(CONFIG_MEDIA_CONTROLLER) + media_entity_cleanup(&device->sd.entity); +#endif v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&device->hdl); kfree(device); diff --git a/include/media/tvp7002.h b/include/media/tvp7002.h index ee43534..7123048 100644 --- a/include/media/tvp7002.h +++ b/include/media/tvp7002.h @@ -26,6 +26,8 @@ #ifndef _TVP7002_H_ #define _TVP7002_H_ +#define TVP7002_MODULE_NAME "tvp7002" + /* Platform-dependent data * * clk_polarity: