drivers/media/pci/bt8xx/bttv-audio-hook.c

Source file repositories/reference/linux-study-clean/drivers/media/pci/bt8xx/bttv-audio-hook.c

File Facts

System
Linux kernel
Corpus path
drivers/media/pci/bt8xx/bttv-audio-hook.c
Extension
.c
Size
10013 bytes
Lines
482
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

switch (t->audmode) {
		case V4L2_TUNER_MODE_LANG2:
			con = 0x300;
			break;
		case V4L2_TUNER_MODE_LANG1_LANG2:
			con = 0x100;
			break;
		default:
			con = 0x000;
			break;
		}
		if (con != (val & 0x300)) {
			gpio_bits(0x300, con);
			if (bttv_gpio)
				bttv_gpio_tracking(btv, "gvbctv5pci");
		}
	} else {
		switch (val & 0x70) {
		  case 0x10:
			t->rxsubchans = V4L2_TUNER_SUB_LANG1 |  V4L2_TUNER_SUB_LANG2;
			t->audmode = V4L2_TUNER_MODE_LANG1_LANG2;
			break;
		  case 0x30:
			t->rxsubchans = V4L2_TUNER_SUB_LANG2;
			t->audmode = V4L2_TUNER_MODE_LANG1_LANG2;
			break;
		  case 0x50:
			t->rxsubchans = V4L2_TUNER_SUB_LANG1;
			t->audmode = V4L2_TUNER_MODE_LANG1_LANG2;
			break;
		  case 0x60:
			t->rxsubchans = V4L2_TUNER_SUB_STEREO;
			t->audmode = V4L2_TUNER_MODE_STEREO;
			break;
		  case 0x70:
			t->rxsubchans = V4L2_TUNER_SUB_MONO;
			t->audmode = V4L2_TUNER_MODE_MONO;
			break;
		  default:
			t->rxsubchans = V4L2_TUNER_SUB_MONO |
					 V4L2_TUNER_SUB_STEREO |
					 V4L2_TUNER_SUB_LANG1 |
					 V4L2_TUNER_SUB_LANG2;
			t->audmode = V4L2_TUNER_MODE_LANG1;
		}
	}
}

/*
 * Mario Medina Nussbaum <medisoft@alohabbs.org.mx>
 *  I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo,
 *  0xdde enables mono and 0xccd enables sap
 *
 * Petr Vandrovec <VANDROVE@vc.cvut.cz>
 *  P.S.: At least mask in line above is wrong - GPIO pins 3,2 select
 *  input/output sound connection, so both must be set for output mode.
 *
 * Looks like it's needed only for the "tvphone", the "tvphone 98"
 * handles this with a tda9840
 *
 */

void avermedia_tvphone_audio(struct bttv *btv, struct v4l2_tuner *t, int set)
{
	int val;

	if (!set) {
		/* Not much to do here */
		t->audmode = V4L2_TUNER_MODE_LANG1;
		t->rxsubchans = V4L2_TUNER_SUB_MONO |
				V4L2_TUNER_SUB_STEREO |
				V4L2_TUNER_SUB_LANG1 |
				V4L2_TUNER_SUB_LANG2;

		return;
	}

	switch (t->audmode) {
	case V4L2_TUNER_MODE_LANG2:   /* SAP */
		val = 0x02;
		break;
	case V4L2_TUNER_MODE_STEREO:
		val = 0x01;
		break;
	default:
		return;
	}
	gpio_bits(0x03, val);
	if (bttv_gpio)
		bttv_gpio_tracking(btv, "avermedia");

Annotation

Implementation Notes