Re: [PATCH 2/6] davinci vpbe: VPBE display driver

2010-11-13 Thread Hans Verkuil
Some minor review comments...

On Monday, November 08, 2010 15:54:25 Manjunath Hadli wrote:
 From: Muralidharan Karicheri m-kariche...@ti.com
 
 This patch implements the coe functionality of the dislay driver,
 mainly controlling the VENC and other encoders, and acting as
 the one point interface for the man V4L2 driver.This implements
 the cre of each of the V4L2 IOCTLs.
 
 Signed-off-by: Muralidharan Karicheri m-kariche...@ti.com
 Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
 ---
  drivers/media/video/davinci/vpbe.c |  861 
 
  include/media/davinci/vpbe.h   |  187 
  2 files changed, 1048 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/video/davinci/vpbe.c
  create mode 100644 include/media/davinci/vpbe.h
 
 diff --git a/drivers/media/video/davinci/vpbe.c 
 b/drivers/media/video/davinci/vpbe.c
 new file mode 100644
 index 000..17ff1e7
 --- /dev/null
 +++ b/drivers/media/video/davinci/vpbe.c
 @@ -0,0 +1,861 @@
 +/*
 + * Copyright (C) 2010 Texas Instruments Inc
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 + */
 +#include linux/kernel.h
 +#include linux/init.h
 +#include linux/module.h
 +#include linux/errno.h
 +#include linux/fs.h
 +#include linux/string.h
 +#include linux/wait.h
 +#include linux/time.h
 +#include linux/platform_device.h
 +#include linux/io.h
 +#include linux/slab.h
 +#include linux/clk.h
 +#include linux/err.h
 +
 +#include media/v4l2-device.h
 +#include media/davinci/vpbe_types.h
 +#include media/davinci/vpbe.h
 +#include media/davinci/vpss.h
 +
 +
 +#define VPBE_DEFAULT_OUTPUT  Composite
 +#define VPBE_DEFAULT_MODEntsc
 +
 +static char *def_output = VPBE_DEFAULT_OUTPUT;
 +static char *def_mode = VPBE_DEFAULT_MODE;
 +static  struct osd_state *osd_device;
 +static int debug;
 +
 +module_param(def_output, charp, S_IRUGO);
 +module_param(def_mode, charp, S_IRUGO);
 +module_param(debug, int, 0644);
 +
 +MODULE_PARM_DESC(def_output, vpbe output name (default:Composite));
 +MODULE_PARM_DESC(ef_mode, vpbe output mode name (default:ntsc);
 +MODULE_PARM_DESC(debug, Debug level 0-1);
 +
 +MODULE_DESCRIPTION(TI DMXXX VPBE Display controller);
 +MODULE_LICENSE(GPL);
 +MODULE_AUTHOR(Texas Instruments);
 +
 +/**
 + * vpbe_current_encoder_info - Get config info for current encoder
 + * @vpbe_dev - vpbe device ptr
 + *
 + * Return ptr to current encoder config info
 + */
 +static struct encoder_config_info*
 +vpbe_current_encoder_info(struct vpbe_device *vpbe_dev)
 +{
 + struct vpbe_display_config *vpbe_config = vpbe_dev-cfg;
 + int index = vpbe_dev-current_sd_index;
 + return ((index == 0) ? vpbe_config-venc :
 + vpbe_config-ext_encoders[index-1]);
 +}
 +
 +/**
 + * vpbe_find_encoder_sd_index - Given a name find encoder sd index
 + *
 + * @vpbe_config - ptr to vpbe cfg
 + * @output_index - index used by application
 + *
 + * Return sd index of the encoder
 + */
 +static int vpbe_find_encoder_sd_index(struct vpbe_display_config 
 *vpbe_config,
 +  int index)
 +{
 + char *encoder_name = vpbe_config-outputs[index].subdev_name;
 + int i;
 +
 + /* Venc is always first */
 + if (!strcmp(encoder_name, vpbe_config-venc.module_name))
 + return 0;
 +
 + for (i = 0; i  vpbe_config-num_ext_encoders; i++) {
 + if (!strcmp(encoder_name,
 +  vpbe_config-ext_encoders[i].module_name))
 + return i+1;
 + }
 + return -EINVAL;
 +}
 +
 +/**
 + * vpbe_g_cropcap - Get crop capabilities of the display
 + * @vpbe_dev - vpbe device ptr
 + * @cropcap - cropcap is a ptr to struct v4l2_cropcap
 + *
 + * Update the crop capabilities in crop cap for current
 + * mode
 + */
 +static int vpbe_g_cropcap(struct vpbe_device *vpbe_dev,
 +   struct v4l2_cropcap *cropcap)
 +{
 + if (NULL == cropcap)
 + return -EINVAL;
 + cropcap-bounds.left = 0;
 + cropcap-bounds.top = 0;
 + cropcap-bounds.width = vpbe_dev-current_timings.xres;
 + cropcap-bounds.height = vpbe_dev-current_timings.yres;
 + cropcap-defrect = cropcap-bounds;
 + return 0;
 +}
 +
 +/**
 + * vpbe_enum_outputs - enumerate outputs
 + * @vpbe_dev - vpbe device ptr
 + * @output - ptr to v4l2_output structure
 + *
 + * Enumerates the outputs available at 

[PATCH 2/6] davinci vpbe: VPBE display driver

2010-11-08 Thread Manjunath Hadli
From: Muralidharan Karicheri m-kariche...@ti.com

This patch implements the coe functionality of the dislay driver,
mainly controlling the VENC and other encoders, and acting as
the one point interface for the man V4L2 driver.This implements
the cre of each of the V4L2 IOCTLs.

Signed-off-by: Muralidharan Karicheri m-kariche...@ti.com
Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
---
 drivers/media/video/davinci/vpbe.c |  861 
 include/media/davinci/vpbe.h   |  187 
 2 files changed, 1048 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/davinci/vpbe.c
 create mode 100644 include/media/davinci/vpbe.h

diff --git a/drivers/media/video/davinci/vpbe.c 
b/drivers/media/video/davinci/vpbe.c
new file mode 100644
index 000..17ff1e7
--- /dev/null
+++ b/drivers/media/video/davinci/vpbe.c
@@ -0,0 +1,861 @@
+/*
+ * Copyright (C) 2010 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include linux/kernel.h
+#include linux/init.h
+#include linux/module.h
+#include linux/errno.h
+#include linux/fs.h
+#include linux/string.h
+#include linux/wait.h
+#include linux/time.h
+#include linux/platform_device.h
+#include linux/io.h
+#include linux/slab.h
+#include linux/clk.h
+#include linux/err.h
+
+#include media/v4l2-device.h
+#include media/davinci/vpbe_types.h
+#include media/davinci/vpbe.h
+#include media/davinci/vpss.h
+
+
+#define VPBE_DEFAULT_OUTPUTComposite
+#define VPBE_DEFAULT_MODE  ntsc
+
+static char *def_output = VPBE_DEFAULT_OUTPUT;
+static char *def_mode = VPBE_DEFAULT_MODE;
+static  struct osd_state *osd_device;
+static int debug;
+
+module_param(def_output, charp, S_IRUGO);
+module_param(def_mode, charp, S_IRUGO);
+module_param(debug, int, 0644);
+
+MODULE_PARM_DESC(def_output, vpbe output name (default:Composite));
+MODULE_PARM_DESC(ef_mode, vpbe output mode name (default:ntsc);
+MODULE_PARM_DESC(debug, Debug level 0-1);
+
+MODULE_DESCRIPTION(TI DMXXX VPBE Display controller);
+MODULE_LICENSE(GPL);
+MODULE_AUTHOR(Texas Instruments);
+
+/**
+ * vpbe_current_encoder_info - Get config info for current encoder
+ * @vpbe_dev - vpbe device ptr
+ *
+ * Return ptr to current encoder config info
+ */
+static struct encoder_config_info*
+vpbe_current_encoder_info(struct vpbe_device *vpbe_dev)
+{
+   struct vpbe_display_config *vpbe_config = vpbe_dev-cfg;
+   int index = vpbe_dev-current_sd_index;
+   return ((index == 0) ? vpbe_config-venc :
+   vpbe_config-ext_encoders[index-1]);
+}
+
+/**
+ * vpbe_find_encoder_sd_index - Given a name find encoder sd index
+ *
+ * @vpbe_config - ptr to vpbe cfg
+ * @output_index - index used by application
+ *
+ * Return sd index of the encoder
+ */
+static int vpbe_find_encoder_sd_index(struct vpbe_display_config *vpbe_config,
+int index)
+{
+   char *encoder_name = vpbe_config-outputs[index].subdev_name;
+   int i;
+
+   /* Venc is always first */
+   if (!strcmp(encoder_name, vpbe_config-venc.module_name))
+   return 0;
+
+   for (i = 0; i  vpbe_config-num_ext_encoders; i++) {
+   if (!strcmp(encoder_name,
+vpbe_config-ext_encoders[i].module_name))
+   return i+1;
+   }
+   return -EINVAL;
+}
+
+/**
+ * vpbe_g_cropcap - Get crop capabilities of the display
+ * @vpbe_dev - vpbe device ptr
+ * @cropcap - cropcap is a ptr to struct v4l2_cropcap
+ *
+ * Update the crop capabilities in crop cap for current
+ * mode
+ */
+static int vpbe_g_cropcap(struct vpbe_device *vpbe_dev,
+ struct v4l2_cropcap *cropcap)
+{
+   if (NULL == cropcap)
+   return -EINVAL;
+   cropcap-bounds.left = 0;
+   cropcap-bounds.top = 0;
+   cropcap-bounds.width = vpbe_dev-current_timings.xres;
+   cropcap-bounds.height = vpbe_dev-current_timings.yres;
+   cropcap-defrect = cropcap-bounds;
+   return 0;
+}
+
+/**
+ * vpbe_enum_outputs - enumerate outputs
+ * @vpbe_dev - vpbe device ptr
+ * @output - ptr to v4l2_output structure
+ *
+ * Enumerates the outputs available at the vpbe display
+ * returns the status, -EINVAL if end of output list
+ */
+static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
+struct v4l2_output