diff options
-rw-r--r-- | drivers/media/video/cx23885/cx23885-core.c | 82 | ||||
-rw-r--r-- | drivers/media/video/cx23885/cx23885.h | 16 |
2 files changed, 98 insertions, 0 deletions
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c index 9e4d37eb918e..eb5e3412d39b 100644 --- a/drivers/media/video/cx23885/cx23885-core.c +++ b/drivers/media/video/cx23885/cx23885-core.c | |||
@@ -1733,6 +1733,88 @@ out: | |||
1733 | return IRQ_RETVAL(handled); | 1733 | return IRQ_RETVAL(handled); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | int encoder_on_portb(struct cx23885_dev *dev) | ||
1737 | { | ||
1738 | return cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER; | ||
1739 | } | ||
1740 | |||
1741 | int encoder_on_portc(struct cx23885_dev *dev) | ||
1742 | { | ||
1743 | return cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER; | ||
1744 | } | ||
1745 | |||
1746 | /* Mask represents 32 different GPIOs, GPIO's are split into multiple | ||
1747 | * registers depending on the board configuration (and whether the | ||
1748 | * 417 encoder (wi it's own GPIO's) are present. Each GPIO bit will | ||
1749 | * be pushed into the correct hardware register, regardless of the | ||
1750 | * physical location. Certain registers are shared so we sanity check | ||
1751 | * and report errors if we think we're tampering with a GPIo that might | ||
1752 | * be assigned to the encoder (and used for the host bus). | ||
1753 | * | ||
1754 | * GPIO 2 thru 0 - On the cx23885 bridge | ||
1755 | * GPIO 18 thru 3 - On the cx23417 host bus interface | ||
1756 | * GPIO 23 thru 19 - On the cx25840 a/v core | ||
1757 | */ | ||
1758 | void cx23885_gpio_set(struct cx23885_dev *dev, u32 mask) | ||
1759 | { | ||
1760 | if (mask & 0x7) | ||
1761 | cx_set(GP0_IO, mask & 0x7); | ||
1762 | |||
1763 | if (mask & 0x0007fff8) { | ||
1764 | if (encoder_on_portb(dev) || encoder_on_portc(dev)) | ||
1765 | printk(KERN_ERR | ||
1766 | "%s: Setting GPIO on encoder ports\n", | ||
1767 | dev->name); | ||
1768 | cx_set(MC417_RWD, (mask & 0x0007fff8) >> 3); | ||
1769 | } | ||
1770 | |||
1771 | /* TODO: 23-19 */ | ||
1772 | if (mask & 0x00f80000) | ||
1773 | printk(KERN_INFO "%s: Unsupported\n", dev->name); | ||
1774 | } | ||
1775 | |||
1776 | void cx23885_gpio_clear(struct cx23885_dev *dev, u32 mask) | ||
1777 | { | ||
1778 | if (mask & 0x00000007) | ||
1779 | cx_clear(GP0_IO, mask & 0x7); | ||
1780 | |||
1781 | if (mask & 0x0007fff8) { | ||
1782 | if (encoder_on_portb(dev) || encoder_on_portc(dev)) | ||
1783 | printk(KERN_ERR | ||
1784 | "%s: Clearing GPIO moving on encoder ports\n", | ||
1785 | dev->name); | ||
1786 | cx_clear(MC417_RWD, (mask & 0x7fff8) >> 3); | ||
1787 | } | ||
1788 | |||
1789 | /* TODO: 23-19 */ | ||
1790 | if (mask & 0x00f80000) | ||
1791 | printk(KERN_INFO "%s: Unsupported\n", dev->name); | ||
1792 | } | ||
1793 | |||
1794 | void cx23885_gpio_enable(struct cx23885_dev *dev, u32 mask, int asoutput) | ||
1795 | { | ||
1796 | if ((mask & 0x00000007) && asoutput) | ||
1797 | cx_set(GP0_IO, (mask & 0x7) << 16); | ||
1798 | else if ((mask & 0x00000007) && !asoutput) | ||
1799 | cx_clear(GP0_IO, (mask & 0x7) << 16); | ||
1800 | |||
1801 | if (mask & 0x0007fff8) { | ||
1802 | if (encoder_on_portb(dev) || encoder_on_portc(dev)) | ||
1803 | printk(KERN_ERR | ||
1804 | "%s: Enabling GPIO on encoder ports\n", | ||
1805 | dev->name); | ||
1806 | } | ||
1807 | |||
1808 | /* MC417_OEN is active low for output, write 1 for an input */ | ||
1809 | if ((mask & 0x0007fff8) && asoutput) | ||
1810 | cx_clear(MC417_OEN, (mask & 0x7fff8) >> 3); | ||
1811 | |||
1812 | else if ((mask & 0x0007fff8) && !asoutput) | ||
1813 | cx_set(MC417_OEN, (mask & 0x7fff8) >> 3); | ||
1814 | |||
1815 | /* TODO: 23-19 */ | ||
1816 | } | ||
1817 | |||
1736 | static int __devinit cx23885_initdev(struct pci_dev *pci_dev, | 1818 | static int __devinit cx23885_initdev(struct pci_dev *pci_dev, |
1737 | const struct pci_device_id *pci_id) | 1819 | const struct pci_device_id *pci_id) |
1738 | { | 1820 | { |
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h index 85642831ea8e..d9b03f83fa31 100644 --- a/drivers/media/video/cx23885/cx23885.h +++ b/drivers/media/video/cx23885/cx23885.h | |||
@@ -72,6 +72,17 @@ | |||
72 | #define CX23885_BOARD_DVBWORLD_2005 16 | 72 | #define CX23885_BOARD_DVBWORLD_2005 16 |
73 | #define CX23885_BOARD_NETUP_DUAL_DVBS2_CI 17 | 73 | #define CX23885_BOARD_NETUP_DUAL_DVBS2_CI 17 |
74 | 74 | ||
75 | #define GPIO_0 0x00000001 | ||
76 | #define GPIO_1 0x00000002 | ||
77 | #define GPIO_2 0x00000004 | ||
78 | #define GPIO_3 0x00000008 | ||
79 | #define GPIO_4 0x00000010 | ||
80 | #define GPIO_5 0x00000020 | ||
81 | #define GPIO_6 0x00000040 | ||
82 | #define GPIO_7 0x00000080 | ||
83 | #define GPIO_8 0x00000100 | ||
84 | #define GPIO_9 0x00000200 | ||
85 | |||
75 | /* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */ | 86 | /* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */ |
76 | #define CX23885_NORMS (\ | 87 | #define CX23885_NORMS (\ |
77 | V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 | \ | 88 | V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 | \ |
@@ -422,6 +433,11 @@ extern int cx23885_restart_queue(struct cx23885_tsport *port, | |||
422 | extern void cx23885_wakeup(struct cx23885_tsport *port, | 433 | extern void cx23885_wakeup(struct cx23885_tsport *port, |
423 | struct cx23885_dmaqueue *q, u32 count); | 434 | struct cx23885_dmaqueue *q, u32 count); |
424 | 435 | ||
436 | extern void cx23885_gpio_set(struct cx23885_dev *dev, u32 mask); | ||
437 | extern void cx23885_gpio_clear(struct cx23885_dev *dev, u32 mask); | ||
438 | extern void cx23885_gpio_enable(struct cx23885_dev *dev, u32 mask, | ||
439 | int asoutput); | ||
440 | |||
425 | 441 | ||
426 | /* ----------------------------------------------------------- */ | 442 | /* ----------------------------------------------------------- */ |
427 | /* cx23885-cards.c */ | 443 | /* cx23885-cards.c */ |