diff options
author | Daniel Scheller <d.scheller@gmx.net> | 2017-08-20 13:41:11 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-08-20 14:31:37 +0300 |
commit | 66cc3d98ea6daa64735d6e72737d8eac0b6e5182 (patch) | |
tree | 0e2226acf9e9dadd5e319a80a1db2d51b7b09642 | |
parent | bae7c75b1155eab295fbe0d504e7cc25a57c0223 (diff) | |
download | linux-66cc3d98ea6daa64735d6e72737d8eac0b6e5182.tar.xz |
media: ddbridge: move device ID table to ddbridge-hw
This further cleans up ddbridge-main from hardware-related data and moves
the exact card type determination into ddbridge-hw.c:get_ddb_info(), right
to the hardware maps/structs. Also, const'ify more structs and pointers.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/pci/ddbridge/ddbridge-core.c | 8 | ||||
-rw-r--r-- | drivers/media/pci/ddbridge/ddbridge-hw.c | 65 | ||||
-rw-r--r-- | drivers/media/pci/ddbridge/ddbridge-hw.h | 19 | ||||
-rw-r--r-- | drivers/media/pci/ddbridge/ddbridge-main.c | 47 | ||||
-rw-r--r-- | drivers/media/pci/ddbridge/ddbridge.h | 2 |
5 files changed, 96 insertions, 45 deletions
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 98a12c644e44..c80e1d8498d3 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -2430,7 +2430,7 @@ static void output_handler(unsigned long data) static struct ddb_regmap *io_regmap(struct ddb_io *io, int link) { - struct ddb_info *info; + const struct ddb_info *info; if (link) info = io->port->dev->link[io->port->lnr].info; @@ -2564,7 +2564,7 @@ void ddb_ports_init(struct ddb *dev) { u32 i, l, p; struct ddb_port *port; - struct ddb_info *info; + const struct ddb_info *info; struct ddb_regmap *rm; for (p = l = 0; l < DDB_MAX_LINK; l++) { @@ -3527,7 +3527,7 @@ static int tempmon_init(struct ddb_link *link, int first_time) static int ddb_init_tempmon(struct ddb_link *link) { - struct ddb_info *info = link->info; + const struct ddb_info *info = link->info; if (!info->tempmon_irq) return 0; @@ -3545,7 +3545,7 @@ static int ddb_init_tempmon(struct ddb_link *link) static int ddb_init_boards(struct ddb *dev) { - struct ddb_info *info; + const struct ddb_info *info; struct ddb_link *link; u32 l; diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c b/drivers/media/pci/ddbridge/ddbridge-hw.c index 317dc865e99c..3b208d5bf4ad 100644 --- a/drivers/media/pci/ddbridge/ddbridge-hw.c +++ b/drivers/media/pci/ddbridge/ddbridge-hw.c @@ -17,6 +17,7 @@ */ #include "ddbridge.h" +#include "ddbridge-hw.h" /******************************************************************************/ @@ -309,3 +310,67 @@ const struct ddb_info ddb_s2_48 = { .board_control = 1, .tempmon_irq = 24, }; + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +#define DDB_DEVID(_device, _subdevice, _info) { \ + .vendor = DDVID, \ + .device = _device, \ + .subvendor = DDVID, \ + .subdevice = _subdevice, \ + .info = &_info } + +static const struct ddb_device_id ddb_device_ids[] = { + /* PCIe devices */ + DDB_DEVID(0x0002, 0x0001, ddb_octopus), + DDB_DEVID(0x0003, 0x0001, ddb_octopus), + DDB_DEVID(0x0005, 0x0004, ddb_octopusv3), + DDB_DEVID(0x0003, 0x0002, ddb_octopus_le), + DDB_DEVID(0x0003, 0x0003, ddb_octopus_oem), + DDB_DEVID(0x0003, 0x0010, ddb_octopus_mini), + DDB_DEVID(0x0005, 0x0011, ddb_octopus_mini), + DDB_DEVID(0x0003, 0x0020, ddb_v6), + DDB_DEVID(0x0003, 0x0021, ddb_v6_5), + DDB_DEVID(0x0006, 0x0022, ddb_v7), + DDB_DEVID(0x0006, 0x0024, ddb_v7a), + DDB_DEVID(0x0003, 0x0030, ddb_dvbct), + DDB_DEVID(0x0003, 0xdb03, ddb_satixS2v3), + DDB_DEVID(0x0006, 0x0031, ddb_ctv7), + DDB_DEVID(0x0006, 0x0032, ddb_ctv7), + DDB_DEVID(0x0006, 0x0033, ddb_ctv7), + DDB_DEVID(0x0007, 0x0023, ddb_s2_48), + DDB_DEVID(0x0008, 0x0034, ddb_ct2_8), + DDB_DEVID(0x0008, 0x0035, ddb_c2t2_8), + DDB_DEVID(0x0008, 0x0036, ddb_isdbt_8), + DDB_DEVID(0x0008, 0x0037, ddb_c2t2i_v0_8), + DDB_DEVID(0x0008, 0x0038, ddb_c2t2i_8), + DDB_DEVID(0x0006, 0x0039, ddb_ctv7), + DDB_DEVID(0x0011, 0x0040, ddb_ci), + DDB_DEVID(0x0011, 0x0041, ddb_cis), + DDB_DEVID(0x0012, 0x0042, ddb_ci), + DDB_DEVID(0x0013, 0x0043, ddb_ci_s2_pro), + DDB_DEVID(0x0013, 0x0044, ddb_ci_s2_pro_a), +}; + +/****************************************************************************/ + +const struct ddb_info *get_ddb_info(u16 vendor, u16 device, + u16 subvendor, u16 subdevice) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(ddb_device_ids); i++) { + const struct ddb_device_id *id = &ddb_device_ids[i]; + + if (vendor == id->vendor && + device == id->device && + subvendor == id->subvendor && + ((subdevice == id->subdevice) || + (id->subdevice == 0xffff))) + return id->info; + } + + return &ddb_none; +} diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.h b/drivers/media/pci/ddbridge/ddbridge-hw.h index d26cd9c977d8..1a985d0a1a97 100644 --- a/drivers/media/pci/ddbridge/ddbridge-hw.h +++ b/drivers/media/pci/ddbridge/ddbridge-hw.h @@ -23,6 +23,20 @@ /******************************************************************************/ +#define DDVID 0xdd01 /* Digital Devices Vendor ID */ + +/******************************************************************************/ + +struct ddb_device_id { + u16 vendor; + u16 device; + u16 subvendor; + u16 subdevice; + const struct ddb_info *info; +}; + +/******************************************************************************/ + extern const struct ddb_info ddb_none; extern const struct ddb_info ddb_octopus; extern const struct ddb_info ddb_octopusv3; @@ -53,4 +67,9 @@ extern const struct ddb_info ddb_c2t2i_8; extern const struct ddb_info ddb_s2_48; +/****************************************************************************/ + +const struct ddb_info *get_ddb_info(u16 vendor, u16 device, + u16 subvendor, u16 subdevice); + #endif /* _DDBRIDGE_HW_H */ diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c index 3cb6bb265172..ec608c496b69 100644 --- a/drivers/media/pci/ddbridge/ddbridge-main.c +++ b/drivers/media/pci/ddbridge/ddbridge-main.c @@ -231,10 +231,12 @@ static int ddb_probe(struct pci_dev *pdev, dev->link[0].ids.vendor = id->vendor; dev->link[0].ids.device = id->device; dev->link[0].ids.subvendor = id->subvendor; - dev->link[0].ids.subdevice = id->subdevice; + dev->link[0].ids.subdevice = pdev->subsystem_device; dev->link[0].dev = dev; - dev->link[0].info = (struct ddb_info *) id->driver_data; + dev->link[0].info = get_ddb_info(id->vendor, id->device, + id->subvendor, pdev->subsystem_device); + dev_info(&pdev->dev, "detected %s\n", dev->link[0].info->name); dev->regs_len = pci_resource_len(dev->pdev, 0); @@ -286,46 +288,11 @@ fail: /****************************************************************************/ /****************************************************************************/ -#define DDVID 0xdd01 /* Digital Devices Vendor ID */ - -#define DDB_DEVICE(_device, _subdevice, _driver_data) { \ - PCI_DEVICE_SUB(DDVID, _device, DDVID, _subdevice), \ - .driver_data = (kernel_ulong_t) &_driver_data } - -#define DDB_DEVICE_ANY(_device) { \ - PCI_DEVICE_SUB(DDVID, _device, DDVID, PCI_ANY_ID), \ - .driver_data = (kernel_ulong_t) &ddb_none } +#define DDB_DEVICE_ANY(_device) \ + { PCI_DEVICE_SUB(DDVID, _device, DDVID, PCI_ANY_ID) } static const struct pci_device_id ddb_id_table[] = { - DDB_DEVICE(0x0002, 0x0001, ddb_octopus), - DDB_DEVICE(0x0003, 0x0001, ddb_octopus), - DDB_DEVICE(0x0005, 0x0004, ddb_octopusv3), - DDB_DEVICE(0x0003, 0x0002, ddb_octopus_le), - DDB_DEVICE(0x0003, 0x0003, ddb_octopus_oem), - DDB_DEVICE(0x0003, 0x0010, ddb_octopus_mini), - DDB_DEVICE(0x0005, 0x0011, ddb_octopus_mini), - DDB_DEVICE(0x0003, 0x0020, ddb_v6), - DDB_DEVICE(0x0003, 0x0021, ddb_v6_5), - DDB_DEVICE(0x0006, 0x0022, ddb_v7), - DDB_DEVICE(0x0006, 0x0024, ddb_v7a), - DDB_DEVICE(0x0003, 0x0030, ddb_dvbct), - DDB_DEVICE(0x0003, 0xdb03, ddb_satixS2v3), - DDB_DEVICE(0x0006, 0x0031, ddb_ctv7), - DDB_DEVICE(0x0006, 0x0032, ddb_ctv7), - DDB_DEVICE(0x0006, 0x0033, ddb_ctv7), - DDB_DEVICE(0x0007, 0x0023, ddb_s2_48), - DDB_DEVICE(0x0008, 0x0034, ddb_ct2_8), - DDB_DEVICE(0x0008, 0x0035, ddb_c2t2_8), - DDB_DEVICE(0x0008, 0x0036, ddb_isdbt_8), - DDB_DEVICE(0x0008, 0x0037, ddb_c2t2i_v0_8), - DDB_DEVICE(0x0008, 0x0038, ddb_c2t2i_8), - DDB_DEVICE(0x0006, 0x0039, ddb_ctv7), - DDB_DEVICE(0x0011, 0x0040, ddb_ci), - DDB_DEVICE(0x0011, 0x0041, ddb_cis), - DDB_DEVICE(0x0012, 0x0042, ddb_ci), - DDB_DEVICE(0x0013, 0x0043, ddb_ci_s2_pro), - DDB_DEVICE(0x0013, 0x0044, ddb_ci_s2_pro_a), - /* in case sub-ids got deleted in flash */ + DDB_DEVICE_ANY(0x0002), DDB_DEVICE_ANY(0x0003), DDB_DEVICE_ANY(0x0005), DDB_DEVICE_ANY(0x0006), diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index 91b58eff951c..60fe5ec93f3d 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -307,7 +307,7 @@ struct ddb_lnb { struct ddb_link { struct ddb *dev; - struct ddb_info *info; + const struct ddb_info *info; u32 nr; u32 regs; spinlock_t lock; |