drivers/media/usb/dvb-usb/a800.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb/a800.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/dvb-usb/a800.c
Extension
.c
Size
4003 bytes
Lines
160
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only
/* DVB USB framework compliant Linux driver for the AVerMedia AverTV DVB-T
 * USB2.0 (A800) DVB-T receiver.
 *
 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
 *
 * Thanks to
 *   - AVerMedia who kindly provided information and
 *   - Glen Harris who suffered from my mistakes during development.
 *
 * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
 */
#include "dibusb.h"

static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS);

DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);

#define deb_rc(args...)   dprintk(debug,0x01,args)

static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
{
	/* do nothing for the AVerMedia */
	return 0;
}

/* assure to put cold to 0 for iManufacturer == 1 */
static int a800_identify_state(struct usb_device *udev,
			       const struct dvb_usb_device_properties *props,
			       const struct dvb_usb_device_description **desc,
			       int *cold)
{
	*cold = udev->descriptor.iManufacturer != 1;
	return 0;
}

static int a800_rc_query(struct dvb_usb_device *d)
{
	int ret = 0;
	u8 *key = kmalloc(5, GFP_KERNEL);
	if (!key)
		return -ENOMEM;

	if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
				0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5,
				2000) != 5) {
		ret = -ENODEV;
		goto out;
	}

	/* Note that extended nec and nec32 are dropped */
	if (key[0] == 1)
		rc_keydown(d->rc_dev, RC_PROTO_NEC,
			   RC_SCANCODE_NEC(key[1], key[3]), 0);
	else if (key[0] == 2)
		rc_repeat(d->rc_dev);
out:
	kfree(key);
	return ret;
}

/* USB Driver stuff */
static struct dvb_usb_device_properties a800_properties;

static int a800_probe(struct usb_interface *intf,
		const struct usb_device_id *id)
{
	return dvb_usb_device_init(intf, &a800_properties,
				   THIS_MODULE, NULL, adapter_nr);
}

/* do not change the order of the ID table */
enum {
	AVERMEDIA_DVBT_USB2_COLD,
	AVERMEDIA_DVBT_USB2_WARM,
};

static const struct usb_device_id a800_table[] = {
	DVB_USB_DEV(AVERMEDIA, AVERMEDIA_DVBT_USB2_COLD),
	DVB_USB_DEV(AVERMEDIA, AVERMEDIA_DVBT_USB2_WARM),
	{ }
};

MODULE_DEVICE_TABLE (usb, a800_table);

static struct dvb_usb_device_properties a800_properties = {
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,

Annotation

Implementation Notes