Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the Auvitek AU0828 USB bridge |
| 3 | * |
Steven Toth | 6d89761 | 2008-09-03 17:12:12 -0300 | [diff] [blame] | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <linux/usb.h> |
| 23 | #include <linux/i2c.h> |
| 24 | #include <linux/i2c-algo-bit.h> |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 25 | #include <media/tveeprom.h> |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 26 | |
| 27 | /* DVB */ |
| 28 | #include "demux.h" |
| 29 | #include "dmxdev.h" |
| 30 | #include "dvb_demux.h" |
| 31 | #include "dvb_frontend.h" |
| 32 | #include "dvb_net.h" |
| 33 | #include "dvbdev.h" |
| 34 | |
| 35 | #include "au0828-reg.h" |
| 36 | #include "au0828-cards.h" |
| 37 | |
| 38 | #define DRIVER_NAME "au0828" |
| 39 | #define URB_COUNT 16 |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 40 | #define URB_BUFSIZE (0xe522) |
| 41 | |
| 42 | struct au0828_board { |
| 43 | char *name; |
| 44 | }; |
| 45 | |
| 46 | struct au0828_dvb { |
| 47 | struct mutex lock; |
| 48 | struct dvb_adapter adapter; |
| 49 | struct dvb_frontend *frontend; |
| 50 | struct dvb_demux demux; |
| 51 | struct dmxdev dmxdev; |
| 52 | struct dmx_frontend fe_hw; |
| 53 | struct dmx_frontend fe_mem; |
| 54 | struct dvb_net net; |
| 55 | int feeding; |
| 56 | }; |
| 57 | |
| 58 | struct au0828_dev { |
| 59 | struct mutex mutex; |
| 60 | struct usb_device *usbdev; |
| 61 | int board; |
| 62 | u8 ctrlmsg[64]; |
| 63 | |
| 64 | /* I2C */ |
| 65 | struct i2c_adapter i2c_adap; |
| 66 | struct i2c_algo_bit_data i2c_algo; |
| 67 | struct i2c_client i2c_client; |
| 68 | u32 i2c_rc; |
| 69 | |
| 70 | /* Digital */ |
| 71 | struct au0828_dvb dvb; |
| 72 | |
| 73 | /* USB / URB Related */ |
| 74 | int urb_streaming; |
| 75 | struct urb *urbs[URB_COUNT]; |
| 76 | |
| 77 | }; |
| 78 | |
| 79 | struct au0828_buff { |
| 80 | struct au0828_dev *dev; |
| 81 | struct urb *purb; |
| 82 | struct list_head buff_list; |
| 83 | }; |
| 84 | |
| 85 | /* ----------------------------------------------------------- */ |
Mauro Carvalho Chehab | 18d73c5 | 2008-04-18 22:12:52 -0300 | [diff] [blame] | 86 | #define au0828_read(dev, reg) au0828_readreg(dev, reg) |
| 87 | #define au0828_write(dev, reg, value) au0828_writereg(dev, reg, value) |
| 88 | #define au0828_andor(dev, reg, mask, value) \ |
| 89 | au0828_writereg(dev, reg, \ |
| 90 | (au0828_readreg(dev, reg) & ~(mask)) | ((value) & (mask))) |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 91 | |
Mauro Carvalho Chehab | 18d73c5 | 2008-04-18 22:12:52 -0300 | [diff] [blame] | 92 | #define au0828_set(dev, reg, bit) au0828_andor(dev, (reg), (bit), (bit)) |
| 93 | #define au0828_clear(dev, reg, bit) au0828_andor(dev, (reg), (bit), 0) |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 94 | |
| 95 | /* ----------------------------------------------------------- */ |
| 96 | /* au0828-core.c */ |
| 97 | extern u32 au0828_read(struct au0828_dev *dev, u16 reg); |
| 98 | extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val); |
Adrian Bunk | b33d24c | 2008-04-25 19:06:03 -0300 | [diff] [blame] | 99 | extern int au0828_debug; |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 100 | |
| 101 | /* ----------------------------------------------------------- */ |
| 102 | /* au0828-cards.c */ |
| 103 | extern struct au0828_board au0828_boards[]; |
| 104 | extern struct usb_device_id au0828_usb_id_table[]; |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 105 | extern void au0828_gpio_setup(struct au0828_dev *dev); |
| 106 | extern int au0828_tuner_callback(void *priv, int command, int arg); |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 107 | extern void au0828_card_setup(struct au0828_dev *dev); |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 108 | |
| 109 | /* ----------------------------------------------------------- */ |
| 110 | /* au0828-i2c.c */ |
| 111 | extern int au0828_i2c_register(struct au0828_dev *dev); |
| 112 | extern int au0828_i2c_unregister(struct au0828_dev *dev); |
| 113 | extern void au0828_call_i2c_clients(struct au0828_dev *dev, |
| 114 | unsigned int cmd, void *arg); |
| 115 | |
| 116 | /* ----------------------------------------------------------- */ |
| 117 | /* au0828-dvb.c */ |
| 118 | extern int au0828_dvb_register(struct au0828_dev *dev); |
| 119 | extern void au0828_dvb_unregister(struct au0828_dev *dev); |
Steven Toth | bc3c613 | 2008-04-18 21:39:11 -0300 | [diff] [blame] | 120 | |
| 121 | #define dprintk(level, fmt, arg...)\ |
Adrian Bunk | b33d24c | 2008-04-25 19:06:03 -0300 | [diff] [blame] | 122 | do { if (au0828_debug & level)\ |
Steven Toth | bc3c613 | 2008-04-18 21:39:11 -0300 | [diff] [blame] | 123 | printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\ |
| 124 | } while (0) |