aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-cards.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-08-15 13:41:57 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:05:16 -0400
commit6a59d64c5cc302e0139ddb1f5e57afceecb14368 (patch)
treee3a14e27b5aca04a4069797893d59df7bc0f8f65 /drivers/media/video/cx88/cx88-cards.c
parentb09a79f5848f2143a8ffc724910743027d5a70e0 (diff)
V4L/DVB (6021): cx88: Copy board information into card state
The cx88 driver state stored the ID of the board type in core->board. Every time the driver need to get some information about the board configuration, it uses the board number as an index into board configuration array. This patch changes it so that the board number is in core->boardnr, and core->board is a copy of the board configuration information. This allows access to board information without the extra indirection. e.g. cx88_boards[core->board].mpeg becomes core->board.mpeg. This has a number of advantages: - The code is simpler to write. - It compiles to be smaller and faster, without needing the extra array lookup to get at the board information. - The cx88_boards array no longer needs to be exported to all cx88 modules. - The boards array can be made const - It should be possible to avoid keeping the (large) cx88_boards array around after the module is loaded. - If module parameters or eeprom info override some board configuration setting, it's not necessary to modify the boards array, which would affect all boards of the same type. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx88/cx88-cards.c')
-rw-r--r--drivers/media/video/cx88/cx88-cards.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index 1fc71a78b926..8be90ad4e910 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -30,7 +30,7 @@
30/* ------------------------------------------------------------------ */ 30/* ------------------------------------------------------------------ */
31/* board config info */ 31/* board config info */
32 32
33struct cx88_board cx88_boards[] = { 33const struct cx88_board cx88_boards[] = {
34 [CX88_BOARD_UNKNOWN] = { 34 [CX88_BOARD_UNKNOWN] = {
35 .name = "UNKNOWN/GENERIC", 35 .name = "UNKNOWN/GENERIC",
36 .tuner_type = UNSET, 36 .tuner_type = UNSET,
@@ -1687,12 +1687,12 @@ static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
1687 return; 1687 return;
1688 } 1688 }
1689 1689
1690 core->has_radio = 1; 1690 core->board.tuner_type = (eeprom_data[6] == 0x13) ?
1691 core->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38; 1691 TUNER_PHILIPS_FM1236_MK3 : TUNER_PHILIPS_FM1216ME_MK3;
1692 1692
1693 printk(KERN_INFO "%s: Leadtek Winfast 2000XP Expert config: " 1693 printk(KERN_INFO "%s: Leadtek Winfast 2000XP Expert config: "
1694 "tuner=%d, eeprom[0]=0x%02x\n", 1694 "tuner=%d, eeprom[0]=0x%02x\n",
1695 core->name, core->tuner_type, eeprom_data[0]); 1695 core->name, core->board.tuner_type, eeprom_data[0]);
1696} 1696}
1697 1697
1698static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) 1698static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
@@ -1700,9 +1700,9 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1700 struct tveeprom tv; 1700 struct tveeprom tv;
1701 1701
1702 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); 1702 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data);
1703 core->tuner_type = tv.tuner_type; 1703 core->board.tuner_type = tv.tuner_type;
1704 core->tuner_formats = tv.tuner_formats; 1704 core->tuner_formats = tv.tuner_formats;
1705 core->has_radio = tv.has_radio; 1705 core->board.radio.type = tv.has_radio ? CX88_RADIO : 0;
1706 1706
1707 /* Make sure we support the board model */ 1707 /* Make sure we support the board model */
1708 switch (tv.model) 1708 switch (tv.model)
@@ -1792,8 +1792,9 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
1792 name ? name : "unknown"); 1792 name ? name : "unknown");
1793 if (NULL == name) 1793 if (NULL == name)
1794 return; 1794 return;
1795 core->tuner_type = gdi_tuner[eeprom_data[0x0d]].id; 1795 core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
1796 core->has_radio = gdi_tuner[eeprom_data[0x0d]].fm; 1796 core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ?
1797 CX88_RADIO : 0;
1797} 1798}
1798 1799
1799/* ----------------------------------------------------------------------- */ 1800/* ----------------------------------------------------------------------- */
@@ -1860,7 +1861,7 @@ void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
1860 1861
1861void cx88_card_setup_pre_i2c(struct cx88_core *core) 1862void cx88_card_setup_pre_i2c(struct cx88_core *core)
1862{ 1863{
1863 switch (core->board) { 1864 switch (core->boardnr) {
1864 case CX88_BOARD_HAUPPAUGE_HVR1300: 1865 case CX88_BOARD_HAUPPAUGE_HVR1300:
1865 /* Bring the 702 demod up before i2c scanning/attach or devices are hidden */ 1866 /* Bring the 702 demod up before i2c scanning/attach or devices are hidden */
1866 /* We leave here with the 702 on the bus */ 1867 /* We leave here with the 702 on the bus */
@@ -1883,7 +1884,7 @@ void cx88_card_setup(struct cx88_core *core)
1883 tveeprom_read(&core->i2c_client,eeprom,sizeof(eeprom)); 1884 tveeprom_read(&core->i2c_client,eeprom,sizeof(eeprom));
1884 } 1885 }
1885 1886
1886 switch (core->board) { 1887 switch (core->boardnr) {
1887 case CX88_BOARD_HAUPPAUGE: 1888 case CX88_BOARD_HAUPPAUGE:
1888 case CX88_BOARD_HAUPPAUGE_ROSLYN: 1889 case CX88_BOARD_HAUPPAUGE_ROSLYN:
1889 if (0 == core->i2c_rc) 1890 if (0 == core->i2c_rc)
@@ -1927,7 +1928,7 @@ void cx88_card_setup(struct cx88_core *core)
1927 msleep(1); 1928 msleep(1);
1928 cx_set(MO_GP0_IO, 0x00000101); 1929 cx_set(MO_GP0_IO, 0x00000101);
1929 if (0 == core->i2c_rc && 1930 if (0 == core->i2c_rc &&
1930 core->board == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID) 1931 core->boardnr == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID)
1931 dvico_fusionhdtv_hybrid_init(core); 1932 dvico_fusionhdtv_hybrid_init(core);
1932 break; 1933 break;
1933 case CX88_BOARD_KWORLD_DVB_T: 1934 case CX88_BOARD_KWORLD_DVB_T:
@@ -1965,14 +1966,10 @@ void cx88_card_setup(struct cx88_core *core)
1965 } 1966 }
1966 break; 1967 break;
1967 } 1968 }
1968 if (cx88_boards[core->board].radio.type == CX88_RADIO)
1969 core->has_radio = 1;
1970} 1969}
1971 1970
1972/* ------------------------------------------------------------------ */ 1971/* ------------------------------------------------------------------ */
1973 1972
1974EXPORT_SYMBOL(cx88_boards);
1975
1976/* 1973/*
1977 * Local variables: 1974 * Local variables:
1978 * c-basic-offset: 8 1975 * c-basic-offset: 8