[PATCH - V3] TVP514x: Migration to sub-device framework

2009-06-17 Thread m-karicheri2
From: Muralidharan Karicheri 

This patch converts TVP514x driver to sub-device framework
from V4L2-int framework. 

NOTE: Please note that this patch was tested on DM355 and DM6446
and not tested on OMAP platform

Changes from v2 based on review comments (Taken over this work from
Vaibhav)

- removed __exit for tvp514x_remove
- removed v4l2_i2c_driver_data and use new model similar to ths7303
- changed state to streaming

TODO:
- Add support for some basic video/core functionality like,
  .g_chip_ident
  .reset
  .g_input_status
- Migration of OMAP master driver to validate this driver
- validate on OMAP boards

Reviewed by :Hans Verkuil 

Signed-off-by: Brijesh Jadav 
Signed-off-by: Hardik Shah 
Signed-off-by: Vaibhav Hiremath 
Signed-off-by: Murali Karicheri 
---
Applies to v4l-dvb repository
 
 drivers/media/video/tvp514x.c  |  875 ++--
 drivers/media/video/tvp514x_regs.h |   10 -
 include/media/tvp514x.h|4 -
 3 files changed, 349 insertions(+), 540 deletions(-)

diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index 3750f7f..6063b57 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -31,7 +31,10 @@
 #include 
 #include 
 #include 
-#include 
+
+#include 
+#include 
+#include 
 #include 
 
 #include "tvp514x_regs.h"
@@ -49,13 +52,11 @@ static int debug;
 module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");
 
-#define dump_reg(client, reg, val) \
-   do {\
-   val = tvp514x_read_reg(client, reg);\
-   v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
-   } while (0)
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION("TVP514X linux decoder driver");
+MODULE_LICENSE("GPL");
 
-/**
+/*
  * enum tvp514x_std - enum for supported standards
  */
 enum tvp514x_std {
@@ -64,15 +65,7 @@ enum tvp514x_std {
STD_INVALID
 };
 
-/**
- * enum tvp514x_state - enum for different decoder states
- */
-enum tvp514x_state {
-   STATE_NOT_DETECTED,
-   STATE_DETECTED
-};
-
-/**
+/*
  * struct tvp514x_std_info - Structure to store standard informations
  * @width: Line width in pixels
  * @height:Number of active lines
@@ -87,35 +80,29 @@ struct tvp514x_std_info {
 };
 
 static struct tvp514x_reg tvp514x_reg_list_default[0x40];
-/**
+/*
  * struct tvp514x_decoder - TVP5146/47 decoder object
- * @v4l2_int_device: Slave handle
- * @tvp514x_slave: Slave pointer which is used by @v4l2_int_device
+ * @sd: Subdevice Slave handle
  * @tvp514x_regs: copy of hw's regs with preset values.
  * @pdata: Board specific
- * @client: I2C client data
- * @id: Entry from I2C table
  * @ver: Chip version
- * @state: TVP5146/47 decoder state - detected or not-detected
+ * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
  * @pix: Current pixel format
  * @num_fmts: Number of formats
  * @fmt_list: Format list
  * @current_std: Current standard
  * @num_stds: Number of standards
  * @std_list: Standards list
- * @route: input and output routing at chip level
+ * @input: Input routing at chip level
+ * @output: Output routing at chip level
  */
 struct tvp514x_decoder {
-   struct v4l2_int_device v4l2_int_device;
-   struct v4l2_int_slave tvp514x_slave;
+   struct v4l2_subdev sd;
struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)];
const struct tvp514x_platform_data *pdata;
-   struct i2c_client *client;
-
-   struct i2c_device_id *id;
 
int ver;
-   enum tvp514x_state state;
+   int streaming;
 
struct v4l2_pix_format pix;
int num_fmts;
@@ -124,8 +111,11 @@ struct tvp514x_decoder {
enum tvp514x_std current_std;
int num_stds;
struct tvp514x_std_info *std_list;
-
-   struct v4l2_routing route;
+   /*
+* Input and Output Routing parameters
+*/
+   u32 input;
+   u32 output;
 };
 
 /* TVP514x default register values */
@@ -191,7 +181,8 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = {
{TOK_TERM, 0, 0},
 };
 
-/* List of image formats supported by TVP5146/47 decoder
+/*
+ * List of image formats supported by TVP5146/47 decoder
  * Currently we are using 8 bit mode only, but can be
  * extended to 10/20 bit mode.
  */
@@ -240,35 +231,29 @@ static struct tvp514x_std_info tvp514x_std_list[] = {
},
/* Standard: need to add for additional standard */
 };
-/*
- * Control structure for Auto Gain
- * This is temporary data, will get replaced once
- * v4l2_ctrl_query_fill supports it.
- */
-static const struct v4l2_queryctrl tvp514x_autogain_ctrl = {
-   .id = V4L2_CID_AUTOGAIN,
-   .name = "Gain, Automatic",
-   .type = V4L2_CTRL_TYPE_BOOLEAN,
-   .minimum = 0,
-   .maximum = 1,
-   .step 

Re: [PATCH (V2)] TVP514x: Migration to sub-device framework

2009-06-14 Thread David Brownell
On Sunday 14 June 2009, Hans Verkuil wrote:
> > +#define dump_reg(sd, reg, val)   \
> >   do {\
> > - val = tvp514x_read_reg(client, reg);\
> > - v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> > + val = tvp514x_read_reg(sd, reg);\
> > + v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> >   } while (0)
> 
> Why not turn this into a static inline function? Much better than a macro.

IMO, too big for either.  Make it a real function.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


tcm825x.c: migrating to sub-device framework? (was: TVP514x: Migration to sub-device framework)

2009-06-14 Thread Hans Verkuil
On Sunday 14 June 2009 14:44:53 Hans Verkuil wrote:
> On Sunday 14 June 2009 12:14:38 Hans Verkuil wrote:
> > On Wednesday 06 May 2009 20:31:33 hvaib...@ti.com wrote:
> > > From: Vaibhav Hiremath 
> > > 
> > > This patch converts TVP514x driver to sub-device framework
> > > from V4L2-int framework.

Now that tvp514x is converted to using v4l2_subdev (pending a few small final
tweaks) there is only one driver left that uses the v4l2-int-device.h API:
tcm825x.c.

What is involved in converting this driver as well? And who can do this?

Regards,

Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH (V2)] TVP514x: Migration to sub-device framework

2009-06-14 Thread Hans Verkuil
On Sunday 14 June 2009 12:14:38 Hans Verkuil wrote:
> On Wednesday 06 May 2009 20:31:33 hvaib...@ti.com wrote:
> > From: Vaibhav Hiremath 
> > 
> > This patch converts TVP514x driver to sub-device framework
> > from V4L2-int framework.
> > 
> > NOTE: Please note that this patch has not been tested on any board,
> >   only compilation/build tested.
> > 
> > Changes (From Previous post):
> > - Added static function to_decoder which will replace all
> >   container_of instances.
> > - "unsigned int" replaced with "u32".
> > - Cleaned up for line indentation.
> > - pdata initialized, was missing in earlier patch.
> > 
> > TODO:
> > - Add support for some basic video/core functionality like,
> > .g_chip_ident
> > .reset
> > .g_input_status
> > - Migration master driver to validate this driver.
> > - validate on Davinci and OMAP boards.
> > 
> > Reviewed By "Hans Verkuil".
> > 
> > Signed-off-by: Brijesh Jadav 
> > Signed-off-by: Hardik Shah 
> > Signed-off-by: Vaibhav Hiremath 
> > ---
> >  drivers/media/video/tvp514x.c  |  854 
> > ++--
> >  drivers/media/video/tvp514x_regs.h |   10 -
> >  include/media/tvp514x.h|4 -
> >  3 files changed, 330 insertions(+), 538 deletions(-)
> > 
> > diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
> > index 4262e60..12b49ad 100644
> > --- a/drivers/media/video/tvp514x.c
> > +++ b/drivers/media/video/tvp514x.c



> > +/*
> >   * tvp514x_remove - decoder driver i2c remove handler
> >   * @client: i2c driver client device structure
> >   *
> > @@ -1460,13 +1301,10 @@ out_free:
> >   */
> >  static int __exit tvp514x_remove(struct i2c_client *client)

This can't be __exit since it is called when the adapter is removed, not when
the driver is removed. And that's perfectly valid even if this driver is
compiled in the kernel instead of as a module.

> >  {
> > -   struct tvp514x_decoder *decoder = i2c_get_clientdata(client);
> > +   struct v4l2_subdev *sd = i2c_get_clientdata(client);
> > +   struct tvp514x_decoder *decoder = to_decoder(sd);
> > 
> > -   if (!client->adapter)
> > -   return -ENODEV; /* our client isn't attached */
> > -
> > -   v4l2_int_device_unregister(&decoder->v4l2_int_device);
> > -   i2c_set_clientdata(client, NULL);
> > +   v4l2_device_unregister_subdev(sd);
> > kfree(decoder);
> > return 0;
> >  }
> > @@ -1485,11 +1323,9 @@ static const struct tvp514x_reg 
> > tvp5146_init_reg_seq[] = {
> > {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> > {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +   {TOK_TERM, 0, 0},
> >  };
> > -static const struct tvp514x_init_seq tvp5146_init = {
> > -   .no_regs = ARRAY_SIZE(tvp5146_init_reg_seq),
> > -   .init_reg_seq = tvp5146_init_reg_seq,
> > -};
> > +
> >  /*
> >   * TVP5147 Init/Power on Sequence
> >   */
> > @@ -1512,22 +1348,18 @@ static const struct tvp514x_reg 
> > tvp5147_init_reg_seq[] ={
> > {TOK_WRITE, REG_VBUS_DATA_ACCESS_NO_VBUS_ADDR_INCR, 0x00},
> > {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +   {TOK_TERM, 0, 0},
> >  };
> > -static const struct tvp514x_init_seq tvp5147_init = {
> > -   .no_regs = ARRAY_SIZE(tvp5147_init_reg_seq),
> > -   .init_reg_seq = tvp5147_init_reg_seq,
> > -};
> > +
> >  /*
> >   * TVP5146M2/TVP5147M1 Init/Power on Sequence
> >   */
> >  static const struct tvp514x_reg tvp514xm_init_reg_seq[] = {
> > {TOK_WRITE, REG_OPERATION_MODE, 0x01},
> > {TOK_WRITE, REG_OPERATION_MODE, 0x00},
> > +   {TOK_TERM, 0, 0},
> >  };
> > -static const struct tvp514x_init_seq tvp514xm_init = {
> > -   .no_regs = ARRAY_SIZE(tvp514xm_init_reg_seq),
> > -   .init_reg_seq = tvp514xm_init_reg_seq,
> > -};
> > +
> >  /*
> >   * I2C Device Table -
> >   *
> > @@ -1535,48 +1367,22 @@ static const struct tvp514x_init_seq tvp514xm_init 
> > = {
> >   * driver_data - Driver data
> >   */
> >  static const struct i2c_device_id tvp514x_id[] = {
> > -   {"tvp5146", (unsigned long)&tvp5146_init},
> > -   {"tvp5146m2", (unsigned long)&tvp514xm_init},
> > -   {"tvp5147", (unsigned long)&tvp5147_init},
> > -   {"tvp5147m1", (unsigned long)&tvp514xm_init},
> > +   {"tvp5146", (unsigned long)tvp5146_init_reg_seq},
> > +   {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq},
> > +   {"tvp5147", (unsigned long)tvp5147_init_reg_seq},
> > +   {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq},
> > {},
> >  };
> > 
> >  MODULE_DEVICE_TABLE(i2c, tvp514x_id);
> > 
> > -static struct i2c_driver tvp514x_i2c_driver = {
> > -   .driver = {
> > -  .name = TVP514X_MODULE_NAME,
> > -  .owner = THIS_MODULE,
> > -  },
> > +static struct v4l2_i2c_driver_data v4l2_i2c_data = {
> > +   .name = TVP514X_MODULE_NAME,
> 
> Please don't use v4l2_i2c_driver_data. That is only necessary if this module
> has to support pre-2.6.26 kernels. Since t

Re: [PATCH (V2)] TVP514x: Migration to sub-device framework

2009-06-14 Thread Hans Verkuil
On Wednesday 06 May 2009 20:31:33 hvaib...@ti.com wrote:
> From: Vaibhav Hiremath 
> 
> This patch converts TVP514x driver to sub-device framework
> from V4L2-int framework.
> 
> NOTE: Please note that this patch has not been tested on any board,
>   only compilation/build tested.
> 
> Changes (From Previous post):
> - Added static function to_decoder which will replace all
>   container_of instances.
> - "unsigned int" replaced with "u32".
> - Cleaned up for line indentation.
> - pdata initialized, was missing in earlier patch.
> 
> TODO:
> - Add support for some basic video/core functionality like,
> .g_chip_ident
>   .reset
>   .g_input_status
> - Migration master driver to validate this driver.
> - validate on Davinci and OMAP boards.
> 
> Reviewed By "Hans Verkuil".
> 
> Signed-off-by: Brijesh Jadav 
> Signed-off-by: Hardik Shah 
> Signed-off-by: Vaibhav Hiremath 
> ---
>  drivers/media/video/tvp514x.c  |  854 
> ++--
>  drivers/media/video/tvp514x_regs.h |   10 -
>  include/media/tvp514x.h|4 -
>  3 files changed, 330 insertions(+), 538 deletions(-)
> 
> diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
> index 4262e60..12b49ad 100644
> --- a/drivers/media/video/tvp514x.c
> +++ b/drivers/media/video/tvp514x.c
> @@ -31,7 +31,11 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
>  #include 
> 
>  #include "tvp514x_regs.h"
> @@ -49,13 +53,13 @@ static int debug;
>  module_param(debug, bool, 0644);
>  MODULE_PARM_DESC(debug, "Debug level (0-1)");
> 
> -#define dump_reg(client, reg, val)   \
> +#define dump_reg(sd, reg, val)   \
>   do {\
> - val = tvp514x_read_reg(client, reg);\
> - v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
> + val = tvp514x_read_reg(sd, reg);\
> + v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
>   } while (0)

Why not turn this into a static inline function? Much better than a macro.

> 
> -/**
> +/*
>   * enum tvp514x_std - enum for supported standards
>   */
>  enum tvp514x_std {
> @@ -64,15 +68,7 @@ enum tvp514x_std {
>   STD_INVALID
>  };
> 
> -/**
> - * enum tvp514x_state - enum for different decoder states
> - */
> -enum tvp514x_state {
> - STATE_NOT_DETECTED,
> - STATE_DETECTED
> -};
> -
> -/**
> +/*
>   * struct tvp514x_std_info - Structure to store standard informations
>   * @width: Line width in pixels
>   * @height:Number of active lines
> @@ -87,35 +83,29 @@ struct tvp514x_std_info {
>  };
> 
>  static struct tvp514x_reg tvp514x_reg_list_default[0x40];
> -/**
> +/*
>   * struct tvp514x_decoder - TVP5146/47 decoder object
> - * @v4l2_int_device: Slave handle
> - * @tvp514x_slave: Slave pointer which is used by @v4l2_int_device
> + * @sd: Subdevice Slave handle
>   * @tvp514x_regs: copy of hw's regs with preset values.
>   * @pdata: Board specific
> - * @client: I2C client data
> - * @id: Entry from I2C table
>   * @ver: Chip version
> - * @state: TVP5146/47 decoder state - detected or not-detected
> + * @state: TVP5146/47 decoder state - enabled or disabled.
>   * @pix: Current pixel format
>   * @num_fmts: Number of formats
>   * @fmt_list: Format list
>   * @current_std: Current standard
>   * @num_stds: Number of standards
>   * @std_list: Standards list
> - * @route: input and output routing at chip level
> + * @input: Input routing at chip level
> + * @output: Output routing at chip level
>   */
>  struct tvp514x_decoder {
> - struct v4l2_int_device v4l2_int_device;
> - struct v4l2_int_slave tvp514x_slave;
> + struct v4l2_subdev sd;
>   struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)];
>   const struct tvp514x_platform_data *pdata;
> - struct i2c_client *client;
> -
> - struct i2c_device_id *id;
> 
>   int ver;
> - enum tvp514x_state state;
> + int state;
> 
>   struct v4l2_pix_format pix;
>   int num_fmts;
> @@ -124,8 +114,11 @@ struct tvp514x_decoder {
>   enum tvp514x_std current_std;
>   int num_stds;
>   struct tvp514x_std_info *std_list;
> -
> - struct v4l2_routing route;
> + /*
> +  * Input and Output Routing parameters
> +  */
> + u32 input;
> + u32 output;
>  };
> 
>  /* TVP514x default register values */
> @@ -191,7 +184,8 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = {
>   {TOK_TERM, 0, 0},
>  };
> 
> -/* List of image formats supported by TVP5146/47 decoder
> +/*
> + * List of image formats supported by TVP5146/47 decoder
>   * Currently we are using 8 bit mode only, but can be
>   * extended to 10/20 bit mode.
>   */
> @@ -240,35 +234,27 @@ static struct tvp514x_std_info tvp514x_std_list[] = {
>   },
>   /* Standard: need to add fo

[PATCH (V2)] TVP514x: Migration to sub-device framework

2009-05-06 Thread hvaibhav
From: Vaibhav Hiremath 

This patch converts TVP514x driver to sub-device framework
from V4L2-int framework.

NOTE: Please note that this patch has not been tested on any board,
  only compilation/build tested.

Changes (From Previous post):
- Added static function to_decoder which will replace all
  container_of instances.
- "unsigned int" replaced with "u32".
- Cleaned up for line indentation.
- pdata initialized, was missing in earlier patch.

TODO:
- Add support for some basic video/core functionality like,
.g_chip_ident
.reset
.g_input_status
- Migration master driver to validate this driver.
- validate on Davinci and OMAP boards.

Reviewed By "Hans Verkuil".

Signed-off-by: Brijesh Jadav 
Signed-off-by: Hardik Shah 
Signed-off-by: Vaibhav Hiremath 
---
 drivers/media/video/tvp514x.c  |  854 ++--
 drivers/media/video/tvp514x_regs.h |   10 -
 include/media/tvp514x.h|4 -
 3 files changed, 330 insertions(+), 538 deletions(-)

diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index 4262e60..12b49ad 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -31,7 +31,11 @@
 #include 
 #include 
 #include 
-#include 
+
+#include 
+#include 
+#include 
+#include 
 #include 

 #include "tvp514x_regs.h"
@@ -49,13 +53,13 @@ static int debug;
 module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");

-#define dump_reg(client, reg, val) \
+#define dump_reg(sd, reg, val) \
do {\
-   val = tvp514x_read_reg(client, reg);\
-   v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+   val = tvp514x_read_reg(sd, reg);\
+   v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
} while (0)

-/**
+/*
  * enum tvp514x_std - enum for supported standards
  */
 enum tvp514x_std {
@@ -64,15 +68,7 @@ enum tvp514x_std {
STD_INVALID
 };

-/**
- * enum tvp514x_state - enum for different decoder states
- */
-enum tvp514x_state {
-   STATE_NOT_DETECTED,
-   STATE_DETECTED
-};
-
-/**
+/*
  * struct tvp514x_std_info - Structure to store standard informations
  * @width: Line width in pixels
  * @height:Number of active lines
@@ -87,35 +83,29 @@ struct tvp514x_std_info {
 };

 static struct tvp514x_reg tvp514x_reg_list_default[0x40];
-/**
+/*
  * struct tvp514x_decoder - TVP5146/47 decoder object
- * @v4l2_int_device: Slave handle
- * @tvp514x_slave: Slave pointer which is used by @v4l2_int_device
+ * @sd: Subdevice Slave handle
  * @tvp514x_regs: copy of hw's regs with preset values.
  * @pdata: Board specific
- * @client: I2C client data
- * @id: Entry from I2C table
  * @ver: Chip version
- * @state: TVP5146/47 decoder state - detected or not-detected
+ * @state: TVP5146/47 decoder state - enabled or disabled.
  * @pix: Current pixel format
  * @num_fmts: Number of formats
  * @fmt_list: Format list
  * @current_std: Current standard
  * @num_stds: Number of standards
  * @std_list: Standards list
- * @route: input and output routing at chip level
+ * @input: Input routing at chip level
+ * @output: Output routing at chip level
  */
 struct tvp514x_decoder {
-   struct v4l2_int_device v4l2_int_device;
-   struct v4l2_int_slave tvp514x_slave;
+   struct v4l2_subdev sd;
struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)];
const struct tvp514x_platform_data *pdata;
-   struct i2c_client *client;
-
-   struct i2c_device_id *id;

int ver;
-   enum tvp514x_state state;
+   int state;

struct v4l2_pix_format pix;
int num_fmts;
@@ -124,8 +114,11 @@ struct tvp514x_decoder {
enum tvp514x_std current_std;
int num_stds;
struct tvp514x_std_info *std_list;
-
-   struct v4l2_routing route;
+   /*
+* Input and Output Routing parameters
+*/
+   u32 input;
+   u32 output;
 };

 /* TVP514x default register values */
@@ -191,7 +184,8 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = {
{TOK_TERM, 0, 0},
 };

-/* List of image formats supported by TVP5146/47 decoder
+/*
+ * List of image formats supported by TVP5146/47 decoder
  * Currently we are using 8 bit mode only, but can be
  * extended to 10/20 bit mode.
  */
@@ -240,35 +234,27 @@ static struct tvp514x_std_info tvp514x_std_list[] = {
},
/* Standard: need to add for additional standard */
 };
-/*
- * Control structure for Auto Gain
- * This is temporary data, will get replaced once
- * v4l2_ctrl_query_fill supports it.
- */
-static const struct v4l2_queryctrl tvp514x_autogain_ctrl = {
-   .id = V4L2_CID_AUTOGAIN,
-   .name = "Gain, Automatic",
-   .type = V4L2_CTRL_TYPE_BOOLEAN,
-   .minimum = 0,
-   .maximum = 1

TVP514x: Migration to sub-device framework

2009-04-30 Thread hvaibhav
From: Vaibhav Hiremath 

This is first version of sub-device framework based
TVP514x decoder driver. Earlier version of TVP514x driver is based
on V4L2-int framework.

Initial version reviewed by "Hans Verkuil".

NOTE: Please note that this patch has not been tested on any board,
  only compilation/build tested.

I will consolidate all the review comments and will incorporate
in the next version, which should also be include validation
of these changes on any of the supported boards.

TODO:
- Add support for some basic video/core functionality like,
.g_chip_ident
.reset
.g_input_status
- Migration master driver to validate this driver.
- validate on Davinci and OMAP boards.

Signed-off-by: Brijesh Jadav 
Signed-off-by: Hardik Shah 
Signed-off-by: Vaibhav Hiremath 
---
 drivers/media/video/tvp514x.c  |  787 ++--
 drivers/media/video/tvp514x_regs.h |   10 -
 include/media/tvp514x.h|4 -
 3 files changed, 310 insertions(+), 491 deletions(-)

diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index 4262e60..d42cef2 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -31,7 +31,10 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 

 #include "tvp514x_regs.h"
@@ -49,10 +52,10 @@ static int debug;
 module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Debug level (0-1)");

-#define dump_reg(client, reg, val) \
+#define dump_reg(sd, reg, val) \
do {\
-   val = tvp514x_read_reg(client, reg);\
-   v4l_info(client, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
+   val = tvp514x_read_reg(sd, reg);\
+   v4l2_info(sd, "Reg(0x%.2X): 0x%.2X\n", reg, val); \
} while (0)

 /**
@@ -65,14 +68,6 @@ enum tvp514x_std {
 };

 /**
- * enum tvp514x_state - enum for different decoder states
- */
-enum tvp514x_state {
-   STATE_NOT_DETECTED,
-   STATE_DETECTED
-};
-
-/**
  * struct tvp514x_std_info - Structure to store standard informations
  * @width: Line width in pixels
  * @height:Number of active lines
@@ -89,33 +84,27 @@ struct tvp514x_std_info {
 static struct tvp514x_reg tvp514x_reg_list_default[0x40];
 /**
  * struct tvp514x_decoder - TVP5146/47 decoder object
- * @v4l2_int_device: Slave handle
- * @tvp514x_slave: Slave pointer which is used by @v4l2_int_device
+ * @sd: Subdevice Slave handle
  * @tvp514x_regs: copy of hw's regs with preset values.
  * @pdata: Board specific
- * @client: I2C client data
- * @id: Entry from I2C table
  * @ver: Chip version
- * @state: TVP5146/47 decoder state - detected or not-detected
+ * @state: TVP5146/47 decoder state - enabled or disabled.
  * @pix: Current pixel format
  * @num_fmts: Number of formats
  * @fmt_list: Format list
  * @current_std: Current standard
  * @num_stds: Number of standards
  * @std_list: Standards list
- * @route: input and output routing at chip level
+ * @input: Input routing at chip level
+ * @output: Output routing at chip level
  */
 struct tvp514x_decoder {
-   struct v4l2_int_device v4l2_int_device;
-   struct v4l2_int_slave tvp514x_slave;
+   struct v4l2_subdev sd;
struct tvp514x_reg tvp514x_regs[ARRAY_SIZE(tvp514x_reg_list_default)];
const struct tvp514x_platform_data *pdata;
-   struct i2c_client *client;
-
-   struct i2c_device_id *id;

int ver;
-   enum tvp514x_state state;
+   int state;

struct v4l2_pix_format pix;
int num_fmts;
@@ -124,8 +113,11 @@ struct tvp514x_decoder {
enum tvp514x_std current_std;
int num_stds;
struct tvp514x_std_info *std_list;
-
-   struct v4l2_routing route;
+   /*
+* Input and Output Routing parameters
+*/
+   unsigned int input;
+   unsigned int output;
 };

 /* TVP514x default register values */
@@ -240,35 +232,22 @@ static struct tvp514x_std_info tvp514x_std_list[] = {
},
/* Standard: need to add for additional standard */
 };
-/*
- * Control structure for Auto Gain
- * This is temporary data, will get replaced once
- * v4l2_ctrl_query_fill supports it.
- */
-static const struct v4l2_queryctrl tvp514x_autogain_ctrl = {
-   .id = V4L2_CID_AUTOGAIN,
-   .name = "Gain, Automatic",
-   .type = V4L2_CTRL_TYPE_BOOLEAN,
-   .minimum = 0,
-   .maximum = 1,
-   .step = 1,
-   .default_value = 1,
-};

 /*
  * Read a value from a register in an TVP5146/47 decoder device.
  * Returns value read if successful, or non-zero (-1) otherwise.
  */
-static int tvp514x_read_reg(struct i2c_client *client, u8 reg)
+static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg)
 {
-   int err;
-   int retry = 0;
+   int err, retry = 0;
+   struct i2c_client *client = v