public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] TVP7002 add support for media controller based usag
@ 2013-01-25  7:01 Prabhakar Lad
  2013-01-25  7:01 ` [PATCH 1/2] media: add support for decoder subdevs along with sensor and others Prabhakar Lad
  2013-01-25  7:01 ` [PATCH 2/2] media: tvp7002: enable TVP7002 decoder for media controller based usage Prabhakar Lad
  0 siblings, 2 replies; 5+ messages in thread
From: Prabhakar Lad @ 2013-01-25  7:01 UTC (permalink / raw)
  To: LMML; +Cc: LKML, Mauro Carvalho Chehab, Hans Verkuil, DLOS, Lad, Prabhakar

From: Lad, Prabhakar <prabhakar.lad@ti.com>

The first patch adds a entry MEDIA_ENT_T_V4L2_SUBDEV_DECODER for decoders
and second patch adds media controller support for tvp7002 decoder.

Manjunath Hadli (2):
  media: add support for decoder subdevs along with sensor and others
  media: tvp7002: enable TVP7002 decoder for media controller based
    usage

 drivers/media/i2c/tvp7002.c |  132 +++++++++++++++++++++++++++++++++++++++++-
 include/media/tvp7002.h     |    2 +
 include/uapi/linux/media.h  |    1 +
 3 files changed, 131 insertions(+), 4 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] media: add support for decoder subdevs along with sensor and others
  2013-01-25  7:01 [PATCH 0/2] TVP7002 add support for media controller based usag Prabhakar Lad
@ 2013-01-25  7:01 ` Prabhakar Lad
  2013-01-25 19:54   ` Sylwester Nawrocki
  2013-01-25  7:01 ` [PATCH 2/2] media: tvp7002: enable TVP7002 decoder for media controller based usage Prabhakar Lad
  1 sibling, 1 reply; 5+ messages in thread
From: Prabhakar Lad @ 2013-01-25  7:01 UTC (permalink / raw)
  To: LMML
  Cc: LKML, Mauro Carvalho Chehab, Hans Verkuil, DLOS, Manjunath Hadli,
	Lad, Prabhakar

From: Manjunath Hadli <manjunath.hadli@ti.com>

A lot of SOCs including Texas Instruments Davinci family mainly use
video decoders as input devices. Here the initial subdevice node
from where the input really comes is this decoder, for which support
is needed as part of the Media Controller infrastructure. This patch
adds an additional flag to include the decoders along with others,
such as the sensor and lens.

Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com>
Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com>
---
 include/uapi/linux/media.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 0ef8833..fa44ed9 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -56,6 +56,7 @@ struct media_device_info {
 #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV + 1)
 #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV + 2)
 #define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV + 3)
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV + 4)
 
 #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] media: tvp7002: enable TVP7002 decoder for media controller based usage
  2013-01-25  7:01 [PATCH 0/2] TVP7002 add support for media controller based usag Prabhakar Lad
  2013-01-25  7:01 ` [PATCH 1/2] media: add support for decoder subdevs along with sensor and others Prabhakar Lad
@ 2013-01-25  7:01 ` Prabhakar Lad
  1 sibling, 0 replies; 5+ messages in thread
From: Prabhakar Lad @ 2013-01-25  7:01 UTC (permalink / raw)
  To: LMML
  Cc: LKML, Mauro Carvalho Chehab, Hans Verkuil, DLOS, Manjunath Hadli,
	Lad, Prabhakar

From: Manjunath Hadli <manjunath.hadli@ti.com>

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 <manjunath.hadli@ti.com>
Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com>
---
 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 <santiago.nunez@ridgerun.com>");
 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:
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] media: add support for decoder subdevs along with sensor and others
  2013-01-25  7:01 ` [PATCH 1/2] media: add support for decoder subdevs along with sensor and others Prabhakar Lad
@ 2013-01-25 19:54   ` Sylwester Nawrocki
  2013-01-26  4:37     ` Prabhakar Lad
  0 siblings, 1 reply; 5+ messages in thread
From: Sylwester Nawrocki @ 2013-01-25 19:54 UTC (permalink / raw)
  To: Prabhakar Lad
  Cc: LMML, LKML, Mauro Carvalho Chehab, Hans Verkuil, DLOS,
	Manjunath Hadli, Lad, Prabhakar

Hi Prahakar,

On 01/25/2013 08:01 AM, Prabhakar Lad wrote:
> From: Manjunath Hadli<manjunath.hadli@ti.com>
>
> A lot of SOCs including Texas Instruments Davinci family mainly use
> video decoders as input devices. Here the initial subdevice node
> from where the input really comes is this decoder, for which support
> is needed as part of the Media Controller infrastructure. This patch
> adds an additional flag to include the decoders along with others,
> such as the sensor and lens.
>
> Signed-off-by: Manjunath Hadli<manjunath.hadli@ti.com>
> Signed-off-by: Lad, Prabhakar<prabhakar.lad@ti.com>
> ---
>   include/uapi/linux/media.h |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index 0ef8833..fa44ed9 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -56,6 +56,7 @@ struct media_device_info {
>   #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV + 1)
>   #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV + 2)
>   #define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV + 3)
> +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV + 4)

Such a new entity type needs to be documented in the media DocBook [1].
It probably also deserves a comment here, as DECODER isn't that obvious
like the other already existing entity types. I heard people referring
to a device that encodes analog (composite) video signal into its digital
representation as an ENCODER. :)


[1] http://hverkuil.home.xs4all.nl/spec/media.html#media-ioc-enum-entities

--

Regards,
Sylwester

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] media: add support for decoder subdevs along with sensor and others
  2013-01-25 19:54   ` Sylwester Nawrocki
@ 2013-01-26  4:37     ` Prabhakar Lad
  0 siblings, 0 replies; 5+ messages in thread
From: Prabhakar Lad @ 2013-01-26  4:37 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: LMML, LKML, Mauro Carvalho Chehab, Hans Verkuil, DLOS,
	Lad, Prabhakar

Hi Sylwester,

On Sat, Jan 26, 2013 at 1:24 AM, Sylwester Nawrocki
<sylvester.nawrocki@gmail.com> wrote:
> Hi Prahakar,
>
>
> On 01/25/2013 08:01 AM, Prabhakar Lad wrote:
>>
>> From: Manjunath Hadli<manjunath.hadli@ti.com>
>>
>> A lot of SOCs including Texas Instruments Davinci family mainly use
>> video decoders as input devices. Here the initial subdevice node
>> from where the input really comes is this decoder, for which support
>> is needed as part of the Media Controller infrastructure. This patch
>> adds an additional flag to include the decoders along with others,
>> such as the sensor and lens.
>>
>> Signed-off-by: Manjunath Hadli<manjunath.hadli@ti.com>
>> Signed-off-by: Lad, Prabhakar<prabhakar.lad@ti.com>
>> ---
>>   include/uapi/linux/media.h |    1 +
>>   1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
>> index 0ef8833..fa44ed9 100644
>> --- a/include/uapi/linux/media.h
>> +++ b/include/uapi/linux/media.h
>> @@ -56,6 +56,7 @@ struct media_device_info {
>>   #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR        (MEDIA_ENT_T_V4L2_SUBDEV +
>> 1)
>>   #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2)
>>   #define MEDIA_ENT_T_V4L2_SUBDEV_LENS  (MEDIA_ENT_T_V4L2_SUBDEV + 3)
>> +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER        (MEDIA_ENT_T_V4L2_SUBDEV +
>> 4)
>
>
> Such a new entity type needs to be documented in the media DocBook [1].
> It probably also deserves a comment here, as DECODER isn't that obvious
> like the other already existing entity types. I heard people referring
> to a device that encodes analog (composite) video signal into its digital
> representation as an ENCODER. :)
>
>
Thanks for pointing it :), I'll document it and post a v2.

Regards,
--Prabhakar Lad

> [1] http://hverkuil.home.xs4all.nl/spec/media.html#media-ioc-enum-entities
>
> --
>
> Regards,
> Sylwester

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-26  4:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-25  7:01 [PATCH 0/2] TVP7002 add support for media controller based usag Prabhakar Lad
2013-01-25  7:01 ` [PATCH 1/2] media: add support for decoder subdevs along with sensor and others Prabhakar Lad
2013-01-25 19:54   ` Sylwester Nawrocki
2013-01-26  4:37     ` Prabhakar Lad
2013-01-25  7:01 ` [PATCH 2/2] media: tvp7002: enable TVP7002 decoder for media controller based usage Prabhakar Lad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox