aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-hdw.c
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2007-11-25 23:53:12 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:02 -0500
commit989eb154eafad00c3b5039a3eca03e108dac1df8 (patch)
tree1a2b0638f473c4d5877188f80bce0efbeee0ded9 /drivers/media/video/pvrusb2/pvrusb2-hdw.c
parent681c739944018d80dbcf7f19997eba97676c7116 (diff)
V4L/DVB (6692): pvrusb2: Centralize device specific attributes into a single place
The pvrusb2 driver currently supports two variants of the Hauppauge PVR USB2. However there are other hardware types potentially supportable, but the driver at the moment is not structured to make it easy to describe these minor variations. This changeset is the first set of changes to make such additional device support possible. Device attributes are held in several tables all contained within pvrusb2-devattr.c; all other device-specific driver behavior now derives from these tables. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-hdw.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c91
1 files changed, 15 insertions, 76 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 4e55a2a84073..c56208456bc0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -41,47 +41,6 @@
41#define TV_MIN_FREQ 55250000L 41#define TV_MIN_FREQ 55250000L
42#define TV_MAX_FREQ 850000000L 42#define TV_MAX_FREQ 850000000L
43 43
44struct usb_device_id pvr2_device_table[] = {
45 [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) },
46 [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) },
47 { }
48};
49
50MODULE_DEVICE_TABLE(usb, pvr2_device_table);
51
52static const char *pvr2_device_names[] = {
53 [PVR2_HDW_TYPE_29XXX] = "WinTV PVR USB2 Model Category 29xxxx",
54 [PVR2_HDW_TYPE_24XXX] = "WinTV PVR USB2 Model Category 24xxxx",
55};
56
57struct pvr2_string_table {
58 const char **lst;
59 unsigned int cnt;
60};
61
62// Names of other client modules to request for 24xxx model hardware
63static const char *pvr2_client_24xxx[] = {
64 "cx25840",
65 "tuner",
66 "wm8775",
67};
68
69// Names of other client modules to request for 29xxx model hardware
70static const char *pvr2_client_29xxx[] = {
71 "msp3400",
72 "saa7115",
73 "tuner",
74};
75
76static struct pvr2_string_table pvr2_client_lists[] = {
77 [PVR2_HDW_TYPE_29XXX] = {
78 pvr2_client_29xxx, ARRAY_SIZE(pvr2_client_29xxx)
79 },
80 [PVR2_HDW_TYPE_24XXX] = {
81 pvr2_client_24xxx, ARRAY_SIZE(pvr2_client_24xxx)
82 },
83};
84
85static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; 44static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
86static DEFINE_MUTEX(pvr2_unit_mtx); 45static DEFINE_MUTEX(pvr2_unit_mtx);
87 46
@@ -394,8 +353,8 @@ static int ctrl_vres_max_get(struct pvr2_ctrl *cptr,int *vp)
394 353
395static int ctrl_vres_min_get(struct pvr2_ctrl *cptr,int *vp) 354static int ctrl_vres_min_get(struct pvr2_ctrl *cptr,int *vp)
396{ 355{
397 /* Actual minimum depends on device type. */ 356 /* Actual minimum depends on device digitizer type. */
398 if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { 357 if (cptr->hdw->hdw_desc->flag_has_cx25840) {
399 *vp = 75; 358 *vp = 75;
400 } else { 359 } else {
401 *vp = 17; 360 *vp = 17;
@@ -1131,23 +1090,8 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
1131 unsigned int pipe; 1090 unsigned int pipe;
1132 int ret; 1091 int ret;
1133 u16 address; 1092 u16 address;
1134 static const char *fw_files_29xxx[] = {
1135 "v4l-pvrusb2-29xxx-01.fw",
1136 };
1137 static const char *fw_files_24xxx[] = {
1138 "v4l-pvrusb2-24xxx-01.fw",
1139 };
1140 static const struct pvr2_string_table fw_file_defs[] = {
1141 [PVR2_HDW_TYPE_29XXX] = {
1142 fw_files_29xxx, ARRAY_SIZE(fw_files_29xxx)
1143 },
1144 [PVR2_HDW_TYPE_24XXX] = {
1145 fw_files_24xxx, ARRAY_SIZE(fw_files_24xxx)
1146 },
1147 };
1148 1093
1149 if ((hdw->hdw_type >= ARRAY_SIZE(fw_file_defs)) || 1094 if (!hdw->hdw_desc->fx2_firmware.cnt) {
1150 (!fw_file_defs[hdw->hdw_type].lst)) {
1151 hdw->fw1_state = FW1_STATE_OK; 1095 hdw->fw1_state = FW1_STATE_OK;
1152 return 0; 1096 return 0;
1153 } 1097 }
@@ -1157,8 +1101,8 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
1157 trace_firmware("pvr2_upload_firmware1"); 1101 trace_firmware("pvr2_upload_firmware1");
1158 1102
1159 ret = pvr2_locate_firmware(hdw,&fw_entry,"fx2 controller", 1103 ret = pvr2_locate_firmware(hdw,&fw_entry,"fx2 controller",
1160 fw_file_defs[hdw->hdw_type].cnt, 1104 hdw->hdw_desc->fx2_firmware.cnt,
1161 fw_file_defs[hdw->hdw_type].lst); 1105 hdw->hdw_desc->fx2_firmware.lst);
1162 if (ret < 0) { 1106 if (ret < 0) {
1163 if (ret == -ENOENT) hdw->fw1_state = FW1_STATE_MISSING; 1107 if (ret == -ENOENT) hdw->fw1_state = FW1_STATE_MISSING;
1164 return ret; 1108 return ret;
@@ -1233,8 +1177,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1233 CX2341X_FIRM_ENC_FILENAME, 1177 CX2341X_FIRM_ENC_FILENAME,
1234 }; 1178 };
1235 1179
1236 if ((hdw->hdw_type != PVR2_HDW_TYPE_29XXX) && 1180 if (hdw->hdw_desc->flag_skip_cx23416_firmware) {
1237 (hdw->hdw_type != PVR2_HDW_TYPE_24XXX)) {
1238 return 0; 1181 return 0;
1239 } 1182 }
1240 1183
@@ -1652,8 +1595,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
1652 unsigned int idx; 1595 unsigned int idx;
1653 struct pvr2_ctrl *cptr; 1596 struct pvr2_ctrl *cptr;
1654 int reloadFl = 0; 1597 int reloadFl = 0;
1655 if ((hdw->hdw_type == PVR2_HDW_TYPE_29XXX) || 1598 if (hdw->hdw_desc->fx2_firmware.cnt) {
1656 (hdw->hdw_type == PVR2_HDW_TYPE_24XXX)) {
1657 if (!reloadFl) { 1599 if (!reloadFl) {
1658 reloadFl = 1600 reloadFl =
1659 (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints 1601 (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints
@@ -1689,17 +1631,11 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
1689 } 1631 }
1690 if (!pvr2_hdw_dev_ok(hdw)) return; 1632 if (!pvr2_hdw_dev_ok(hdw)) return;
1691 1633
1692 if (hdw->hdw_type < ARRAY_SIZE(pvr2_client_lists)) { 1634 for (idx = 0; idx < hdw->hdw_desc->client_modules.cnt; idx++) {
1693 for (idx = 0; 1635 request_module(hdw->hdw_desc->client_modules.lst[idx]);
1694 idx < pvr2_client_lists[hdw->hdw_type].cnt;
1695 idx++) {
1696 request_module(
1697 pvr2_client_lists[hdw->hdw_type].lst[idx]);
1698 }
1699 } 1636 }
1700 1637
1701 if ((hdw->hdw_type == PVR2_HDW_TYPE_29XXX) || 1638 if (!hdw->hdw_desc->flag_no_powerup) {
1702 (hdw->hdw_type == PVR2_HDW_TYPE_24XXX)) {
1703 pvr2_hdw_cmd_powerup(hdw); 1639 pvr2_hdw_cmd_powerup(hdw);
1704 if (!pvr2_hdw_dev_ok(hdw)) return; 1640 if (!pvr2_hdw_dev_ok(hdw)) return;
1705 } 1641 }
@@ -1857,20 +1793,22 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1857 unsigned int hdw_type; 1793 unsigned int hdw_type;
1858 int valid_std_mask; 1794 int valid_std_mask;
1859 struct pvr2_ctrl *cptr; 1795 struct pvr2_ctrl *cptr;
1796 const struct pvr2_device_desc *hdw_desc;
1860 __u8 ifnum; 1797 __u8 ifnum;
1861 struct v4l2_queryctrl qctrl; 1798 struct v4l2_queryctrl qctrl;
1862 struct pvr2_ctl_info *ciptr; 1799 struct pvr2_ctl_info *ciptr;
1863 1800
1864 hdw_type = devid - pvr2_device_table; 1801 hdw_type = devid - pvr2_device_table;
1865 if (hdw_type >= ARRAY_SIZE(pvr2_device_names)) { 1802 if (hdw_type >= pvr2_device_count) {
1866 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1803 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1867 "Bogus device type of %u reported",hdw_type); 1804 "Bogus device type of %u reported",hdw_type);
1868 return NULL; 1805 return NULL;
1869 } 1806 }
1807 hdw_desc = pvr2_device_descriptions + hdw_type;
1870 1808
1871 hdw = kzalloc(sizeof(*hdw),GFP_KERNEL); 1809 hdw = kzalloc(sizeof(*hdw),GFP_KERNEL);
1872 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_create: hdw=%p, type \"%s\"", 1810 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_create: hdw=%p, type \"%s\"",
1873 hdw,pvr2_device_names[hdw_type]); 1811 hdw,hdw_desc->description);
1874 if (!hdw) goto fail; 1812 if (!hdw) goto fail;
1875 1813
1876 init_timer(&hdw->quiescent_timer); 1814 init_timer(&hdw->quiescent_timer);
@@ -1894,6 +1832,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1894 GFP_KERNEL); 1832 GFP_KERNEL);
1895 if (!hdw->controls) goto fail; 1833 if (!hdw->controls) goto fail;
1896 hdw->hdw_type = hdw_type; 1834 hdw->hdw_type = hdw_type;
1835 hdw->hdw_desc = hdw_desc;
1897 for (idx = 0; idx < hdw->control_cnt; idx++) { 1836 for (idx = 0; idx < hdw->control_cnt; idx++) {
1898 cptr = hdw->controls + idx; 1837 cptr = hdw->controls + idx;
1899 cptr->hdw = hdw; 1838 cptr->hdw = hdw;