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

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

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/dvb-usb/dib0700_core.c
Extension
.c
Size
24220 bytes
Lines
949
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

struct dib0700_rc_response {
	u8 report_id;
	u8 data_state;
	union {
		struct {
			u8 system;
			u8 not_system;
			u8 data;
			u8 not_data;
		} nec;
		struct {
			u8 not_used;
			u8 system;
			u8 data;
			u8 not_data;
		} rc5;
	};
};
#define RC_MSG_SIZE_V1_20 6

static void dib0700_rc_urb_completion(struct urb *purb)
{
	struct dvb_usb_device *d = purb->context;
	struct dib0700_rc_response *poll_reply;
	enum rc_proto protocol;
	u32 keycode;
	u8 toggle;

	deb_info("%s()\n", __func__);
	if (d->rc_dev == NULL) {
		/* This will occur if disable_rc_polling=1 */
		kfree(purb->transfer_buffer);
		usb_free_urb(purb);
		return;
	}

	poll_reply = purb->transfer_buffer;

	if (purb->status < 0) {
		deb_info("discontinuing polling\n");
		kfree(purb->transfer_buffer);
		usb_free_urb(purb);
		return;
	}

	if (purb->actual_length != RC_MSG_SIZE_V1_20) {
		deb_info("malformed rc msg size=%d\n", purb->actual_length);
		goto resubmit;
	}

	deb_data("IR ID = %02X state = %02X System = %02X %02X Cmd = %02X %02X (len %d)\n",
		 poll_reply->report_id, poll_reply->data_state,
		 poll_reply->nec.system, poll_reply->nec.not_system,
		 poll_reply->nec.data, poll_reply->nec.not_data,
		 purb->actual_length);

	switch (d->props.rc.core.protocol) {
	case RC_PROTO_BIT_NEC:
		toggle = 0;

		/* NEC protocol sends repeat code as 0 0 0 FF */
		if (poll_reply->nec.system     == 0x00 &&
		    poll_reply->nec.not_system == 0x00 &&
		    poll_reply->nec.data       == 0x00 &&
		    poll_reply->nec.not_data   == 0xff) {
			poll_reply->data_state = 2;
			rc_repeat(d->rc_dev);
			goto resubmit;
		}

		if ((poll_reply->nec.data ^ poll_reply->nec.not_data) != 0xff) {
			deb_data("NEC32 protocol\n");
			keycode = RC_SCANCODE_NEC32(poll_reply->nec.system     << 24 |
						     poll_reply->nec.not_system << 16 |
						     poll_reply->nec.data       << 8  |
						     poll_reply->nec.not_data);
			protocol = RC_PROTO_NEC32;
		} else if ((poll_reply->nec.system ^ poll_reply->nec.not_system) != 0xff) {
			deb_data("NEC extended protocol\n");
			keycode = RC_SCANCODE_NECX(poll_reply->nec.system << 8 |
						    poll_reply->nec.not_system,
						    poll_reply->nec.data);

			protocol = RC_PROTO_NECX;
		} else {
			deb_data("NEC normal protocol\n");
			keycode = RC_SCANCODE_NEC(poll_reply->nec.system,
						   poll_reply->nec.data);
			protocol = RC_PROTO_NEC;
		}

Annotation

Implementation Notes