Re: [PATCH 06/11] add the generic file

2009-12-09 Thread Mauro Carvalho Chehab
Sorry for not analysing this module earlier.

The way you ordered your patch series is weird and will break git bisect,
if committed on your order. So, I'm starting analizing with this patch.
I'll let the initial ones to the end.

You should send Makefile/Kconfig changes at the end of the patch series, to
avoid breaking compilation in the middle of your patch series.



Cheers,
Mauro.

Huang Shijie wrote:
 pd-main.c contains the -probe(), it privides the generic
 functions for analog TV,DVB-T and radio.
 
 Signed-off-by: Huang Shijie shij...@gmail.com
 ---
  drivers/media/video/tlg2300/pd-main.c |  546 
 +
  1 files changed, 546 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/video/tlg2300/pd-main.c
 
 diff --git a/drivers/media/video/tlg2300/pd-main.c 
 b/drivers/media/video/tlg2300/pd-main.c
 new file mode 100644
 index 000..f997e2d
 --- /dev/null
 +++ b/drivers/media/video/tlg2300/pd-main.c
 @@ -0,0 +1,546 @@
 +/*
 + * device driver for Telegent tlg2300 based TV cards
 + *
 + * Author :
 + *   Kang Yong   kangy...@telegent.com
 + *   Zhang Xiaobing  xbzh...@telegent.com
 + *   Huang Shijiezyz...@telegent.com or shij...@hotmail.com
 + *
 + *   (c) 2009 Telegent Systems
 + *
 + *  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, or
 + *  (at your option) any later version.
 + *
 + *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 + */
 +
 +#include linux/version.h
 +#include linux/kernel.h
 +#include linux/errno.h
 +#include linux/init.h
 +#include linux/slab.h
 +#include linux/module.h
 +#include linux/kref.h
 +#include linux/usb.h
 +#include linux/suspend.h
 +#include linux/usb/quirks.h
 +#include linux/ctype.h
 +#include linux/string.h
 +#include linux/types.h
 +#include linux/firmware.h
 +#include linux/smp_lock.h
 +#include vendorcmds.h
 +#include pd-common.h
 +
 +#define VENDOR_ID0x1B24
 +#define PRODUCT_ID   0x4001
 +static struct usb_device_id id_table[] = {
 + { USB_DEVICE_AND_INTERFACE_INFO(VENDOR_ID, PRODUCT_ID, 255, 1, 0) },
 + { USB_DEVICE_AND_INTERFACE_INFO(VENDOR_ID, PRODUCT_ID, 255, 1, 1) },
 + { },
 +};
 +MODULE_DEVICE_TABLE(usb, id_table);
 +
 +int debug_mode;
 +module_param(debug_mode, int, 0644);
 +MODULE_PARM_DESC(debug_mode, 0 = disable, 1 = enable, 2 = verbose);
 +
 +const char *firmware_name = tlg2300_firmware.bin;
 +struct usb_driver poseidon_driver;
 +LIST_HEAD(pd_device_list); /*should add a lock*/
 +
 +/*
 + * send set request to USB firmware.
 + */
 +s32 send_set_req(struct poseidon *pd, u8 cmdid, s32 param, s32 *cmd_status)
 +{
 + s32 ret;
 + s8  data[32] = {};
 + u16 lower_16, upper_16;
 +
 + if (pd-state  POSEIDON_STATE_DISCONNECT)
 + return -ENODEV;
 +
 + mdelay(30);
 +
 + if (param == 0) {
 + upper_16 = lower_16 = 0;
 + } else {
 + /* send 32 bit param as  two 16 bit param,little endian */
 + lower_16 = (unsigned short)(param  0x);
 + upper_16 = (unsigned short)((param  16)  0x);
 + }
 + ret = usb_control_msg(pd-udev,
 +  usb_rcvctrlpipe(pd-udev, 0),
 +  REQ_SET_CMD | cmdid,
 +  USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 +  lower_16,
 +  upper_16,
 +  data,
 +  sizeof(*cmd_status),
 +  USB_CTRL_GET_TIMEOUT);
 +
 + if (!ret) {
 + return -ENXIO;
 + } else {
 + /*  1st 4 bytes into cmd_status   */
 + memcpy((char *)cmd_status, (data[0]), sizeof(*cmd_status));
 + }
 + return 0;
 +}
 +
 +/*
 + * send get request to Poseidon firmware.
 + */
 +s32 send_get_req(struct poseidon *pd, u8 cmdid, s32 param,
 + void *buf, s32 *cmd_status, s32 datalen)
 +{
 + s32 ret;
 + s8 data[128] = {};
 + u16 lower_16, upper_16;
 +
 + if (pd-state  POSEIDON_STATE_DISCONNECT)
 + return -ENODEV;
 +
 + mdelay(30);
 + if (param == 0) {
 + upper_16 = lower_16 = 0;
 + } else {
 + /*send 32 bit param as two 16 bit param, little endian */
 + lower_16 = (unsigned short)(param  0x);
 + upper_16 = (unsigned short)((param  16)  0x);
 + }

You're using host endian here, not little endian. If you want to use little 
endian,
you should 

Re: [PATCH 06/11] add the generic file

2009-11-22 Thread Huang Shijie

 +#ifdef CONFIG_PM
 +/* Is the card working now ? */
 +static inline int is_working(struct poseidon *pd)
 +{
 + if (pd-state  POSEIDON_STATE_IDLE_HIBERANTION)
 + return 0;
 + return pd-interface-pm_usage_cnt  0;
 +}
 +
 +static int poseidon_suspend(struct usb_interface *intf, pm_message_t msg)
 +{
 + struct poseidon *pd = usb_get_intfdata(intf);
 +
 + if (!is_working(pd)) {
 + if (pd-interface-pm_usage_cnt = 0
   
`interface-pm_usage_cnt` has been changed to atomic_t type in the latest code. 

 +  !in_hibernation(pd)) {
 + pd-msg.event = PM_EVENT_AUTO_SUSPEND;
 + pd-pm_resume = NULL; /*  a good guard */
 + printk(KERN_DEBUG \n\t ++ TLG2300 auto suspend ++\n);
 + }
 + return 0;
 + }
 + pd-msg = msg;
   

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


[PATCH 06/11] add the generic file

2009-11-19 Thread Huang Shijie
pd-main.c contains the -probe(), it privides the generic
functions for analog TV,DVB-T and radio.

Signed-off-by: Huang Shijie shij...@gmail.com
---
 drivers/media/video/tlg2300/pd-main.c |  546 +
 1 files changed, 546 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/tlg2300/pd-main.c

diff --git a/drivers/media/video/tlg2300/pd-main.c 
b/drivers/media/video/tlg2300/pd-main.c
new file mode 100644
index 000..f997e2d
--- /dev/null
+++ b/drivers/media/video/tlg2300/pd-main.c
@@ -0,0 +1,546 @@
+/*
+ * device driver for Telegent tlg2300 based TV cards
+ *
+ * Author :
+ * Kang Yong   kangy...@telegent.com
+ * Zhang Xiaobing  xbzh...@telegent.com
+ * Huang Shijiezyz...@telegent.com or shij...@hotmail.com
+ *
+ * (c) 2009 Telegent Systems
+ *
+ *  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, or
+ *  (at your option) any later version.
+ *
+ *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include linux/version.h
+#include linux/kernel.h
+#include linux/errno.h
+#include linux/init.h
+#include linux/slab.h
+#include linux/module.h
+#include linux/kref.h
+#include linux/usb.h
+#include linux/suspend.h
+#include linux/usb/quirks.h
+#include linux/ctype.h
+#include linux/string.h
+#include linux/types.h
+#include linux/firmware.h
+#include linux/smp_lock.h
+#include vendorcmds.h
+#include pd-common.h
+
+#define VENDOR_ID  0x1B24
+#define PRODUCT_ID 0x4001
+static struct usb_device_id id_table[] = {
+   { USB_DEVICE_AND_INTERFACE_INFO(VENDOR_ID, PRODUCT_ID, 255, 1, 0) },
+   { USB_DEVICE_AND_INTERFACE_INFO(VENDOR_ID, PRODUCT_ID, 255, 1, 1) },
+   { },
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+int debug_mode;
+module_param(debug_mode, int, 0644);
+MODULE_PARM_DESC(debug_mode, 0 = disable, 1 = enable, 2 = verbose);
+
+const char *firmware_name = tlg2300_firmware.bin;
+struct usb_driver poseidon_driver;
+LIST_HEAD(pd_device_list); /*should add a lock*/
+
+/*
+ * send set request to USB firmware.
+ */
+s32 send_set_req(struct poseidon *pd, u8 cmdid, s32 param, s32 *cmd_status)
+{
+   s32 ret;
+   s8  data[32] = {};
+   u16 lower_16, upper_16;
+
+   if (pd-state  POSEIDON_STATE_DISCONNECT)
+   return -ENODEV;
+
+   mdelay(30);
+
+   if (param == 0) {
+   upper_16 = lower_16 = 0;
+   } else {
+   /* send 32 bit param as  two 16 bit param,little endian */
+   lower_16 = (unsigned short)(param  0x);
+   upper_16 = (unsigned short)((param  16)  0x);
+   }
+   ret = usb_control_msg(pd-udev,
+usb_rcvctrlpipe(pd-udev, 0),
+REQ_SET_CMD | cmdid,
+USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+lower_16,
+upper_16,
+data,
+sizeof(*cmd_status),
+USB_CTRL_GET_TIMEOUT);
+
+   if (!ret) {
+   return -ENXIO;
+   } else {
+   /*  1st 4 bytes into cmd_status   */
+   memcpy((char *)cmd_status, (data[0]), sizeof(*cmd_status));
+   }
+   return 0;
+}
+
+/*
+ * send get request to Poseidon firmware.
+ */
+s32 send_get_req(struct poseidon *pd, u8 cmdid, s32 param,
+   void *buf, s32 *cmd_status, s32 datalen)
+{
+   s32 ret;
+   s8 data[128] = {};
+   u16 lower_16, upper_16;
+
+   if (pd-state  POSEIDON_STATE_DISCONNECT)
+   return -ENODEV;
+
+   mdelay(30);
+   if (param == 0) {
+   upper_16 = lower_16 = 0;
+   } else {
+   /*send 32 bit param as two 16 bit param, little endian */
+   lower_16 = (unsigned short)(param  0x);
+   upper_16 = (unsigned short)((param  16)  0x);
+   }
+   ret = usb_control_msg(pd-udev,
+usb_rcvctrlpipe(pd-udev, 0),
+REQ_GET_CMD | cmdid,
+USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+lower_16,
+upper_16,
+data,
+(datalen + sizeof(*cmd_status)),
+USB_CTRL_GET_TIMEOUT);
+
+   if (ret  0) {
+   return -ENXIO;
+   } else {
+   /* 1st 4 bytes into cmd_status,