linux/drivers/media/usb/dvb-usb/a800.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2/* DVB USB framework compliant Linux driver for the AVerMedia AverTV DVB-T
   3 * USB2.0 (A800) DVB-T receiver.
   4 *
   5 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
   6 *
   7 * Thanks to
   8 *   - AVerMedia who kindly provided information and
   9 *   - Glen Harris who suffered from my mistakes during development.
  10 *
  11 * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  12 */
  13#include "dibusb.h"
  14
  15static int debug;
  16module_param(debug, int, 0644);
  17MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS);
  18
  19DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  20
  21#define deb_rc(args...)   dprintk(debug,0x01,args)
  22
  23static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
  24{
  25        /* do nothing for the AVerMedia */
  26        return 0;
  27}
  28
  29/* assure to put cold to 0 for iManufacturer == 1 */
  30static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
  31        struct dvb_usb_device_description **desc, int *cold)
  32{
  33        *cold = udev->descriptor.iManufacturer != 1;
  34        return 0;
  35}
  36
  37static int a800_rc_query(struct dvb_usb_device *d)
  38{
  39        int ret = 0;
  40        u8 *key = kmalloc(5, GFP_KERNEL);
  41        if (!key)
  42                return -ENOMEM;
  43
  44        if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
  45                                0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5,
  46                                2000) != 5) {
  47                ret = -ENODEV;
  48                goto out;
  49        }
  50
  51        /* Note that extended nec and nec32 are dropped */
  52        if (key[0] == 1)
  53                rc_keydown(d->rc_dev, RC_PROTO_NEC,
  54                           RC_SCANCODE_NEC(key[1], key[3]), 0);
  55        else if (key[0] == 2)
  56                rc_repeat(d->rc_dev);
  57out:
  58        kfree(key);
  59        return ret;
  60}
  61
  62/* USB Driver stuff */
  63static struct dvb_usb_device_properties a800_properties;
  64
  65static int a800_probe(struct usb_interface *intf,
  66                const struct usb_device_id *id)
  67{
  68        return dvb_usb_device_init(intf, &a800_properties,
  69                                   THIS_MODULE, NULL, adapter_nr);
  70}
  71
  72/* do not change the order of the ID table */
  73static struct usb_device_id a800_table [] = {
  74/* 00 */        { USB_DEVICE(USB_VID_AVERMEDIA,     USB_PID_AVERMEDIA_DVBT_USB2_COLD) },
  75/* 01 */        { USB_DEVICE(USB_VID_AVERMEDIA,     USB_PID_AVERMEDIA_DVBT_USB2_WARM) },
  76                        { }             /* Terminating entry */
  77};
  78MODULE_DEVICE_TABLE (usb, a800_table);
  79
  80static struct dvb_usb_device_properties a800_properties = {
  81        .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  82
  83        .usb_ctrl = CYPRESS_FX2,
  84        .firmware = "dvb-usb-avertv-a800-02.fw",
  85
  86        .num_adapters = 1,
  87        .adapter = {
  88                {
  89                .num_frontends = 1,
  90                .fe = {{
  91                        .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
  92                        .pid_filter_count = 32,
  93                        .streaming_ctrl   = dibusb2_0_streaming_ctrl,
  94                        .pid_filter       = dibusb_pid_filter,
  95                        .pid_filter_ctrl  = dibusb_pid_filter_ctrl,
  96
  97                        .frontend_attach  = dibusb_dib3000mc_frontend_attach,
  98                        .tuner_attach     = dibusb_dib3000mc_tuner_attach,
  99
 100                        /* parameter for the MPEG2-data transfer */
 101                                        .stream = {
 102                                                .type = USB_BULK,
 103                                .count = 7,
 104                                .endpoint = 0x06,
 105                                .u = {
 106                                        .bulk = {
 107                                                .buffersize = 4096,
 108                                        }
 109                                }
 110                        },
 111                }},
 112                        .size_of_priv     = sizeof(struct dibusb_state),
 113                },
 114        },
 115
 116        .power_ctrl       = a800_power_ctrl,
 117        .identify_state   = a800_identify_state,
 118
 119        .rc.core = {
 120                .rc_interval    = DEFAULT_RC_INTERVAL,
 121                .rc_codes       = RC_MAP_AVERMEDIA_M135A,
 122                .module_name    = KBUILD_MODNAME,
 123                .rc_query       = a800_rc_query,
 124                .allowed_protos = RC_PROTO_BIT_NEC,
 125        },
 126
 127        .i2c_algo         = &dibusb_i2c_algo,
 128
 129        .generic_bulk_ctrl_endpoint = 0x01,
 130        .num_device_descs = 1,
 131        .devices = {
 132                {   "AVerMedia AverTV DVB-T USB 2.0 (A800)",
 133                        { &a800_table[0], NULL },
 134                        { &a800_table[1], NULL },
 135                },
 136        }
 137};
 138
 139static struct usb_driver a800_driver = {
 140        .name           = "dvb_usb_a800",
 141        .probe          = a800_probe,
 142        .disconnect = dvb_usb_device_exit,
 143        .id_table       = a800_table,
 144};
 145
 146module_usb_driver(a800_driver);
 147
 148MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 149MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)");
 150MODULE_VERSION("1.0");
 151MODULE_LICENSE("GPL");
 152