Skip to contentSkip to conversation

new driver for TLV320AIC23B

PATCH In review Scott Alfter 4 participants 4 messages May 10, 2006 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 new driver for TLV320AIC23B

It took a little bit longer than I thought, but the attached patch adds a driver for the TI TLV320AIC23B audio codec. It implements analog audio capture at 32, 44.1, and 48 kHz (16-bit stereo). The hardware is capable of more (it supports more sample rates and includes analog output), but in its current form, the driver works well with ivtv.

The patch is attached; a test mailing indicated that Thunderbird attaches patches inline instead of encoded. The patch is also available from this URL:

http://alfter.us/files/linux-2.6.16-tlv320aic23b.patch

Scott Alfter
[email protected]

drivers/media/video/Makefile +1 -1
diff -Nupr -X dontdiff linux-2.6.16-gentoo-r1/drivers/media/video/Makefile linux-2.6.16-gentoo-r1/drivers/media/video/Makefile
@@ -45,7 +45,7 @@ obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2
 obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
 obj-$(CONFIG_VIDEO_EM28XX) += saa711x.o tvp5150.o
-obj-$(CONFIG_VIDEO_AUDIO_DECODER) += wm8775.o cs53l32a.o
+obj-$(CONFIG_VIDEO_AUDIO_DECODER) += wm8775.o cs53l32a.o tlv320aic23b.o
 obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
 obj-$(CONFIG_VIDEO_MXB) += saa7111.o tuner.o tda9840.o tea6415c.o tea6420.o mxb.o
 obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o
drivers/media/video/tlv320aic23b.c +248 -0

248 lines not on this page · raw message

drivers/media/video/tlv320aic23b.mod.c +44 -0

44 lines not on this page · raw message

#1 lore raw
Quoted 11 lines · Scott Alfter

the attached patch adds a
driver for the TI TLV320AIC23B audio codec. It implements analog audio capture at 32, 44.1, and 48 kHz (16-bit stereo). The hardware is capable of more (it supports more sample rates and includes analog output), but in its current form, the driver works well with ivtv.

drivers/media/video/tlv320aic23b.c +2 -0
 
+static int tlv320aic23b_attach(struct i2c_adapter *adapter, int address, int kind)
+{

drivers/media/video/tlv320aic23b.c line 172

Quoted 10 lines
drivers/media/video/tlv320aic23b.c +10 -0
+	struct i2c_client *client;
+	struct tlv320aic23b_state *state;
+
+	/* Check if the adapter supports the needed features */
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		return 0;
+
+	client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
+	if (client == 0)
+		return -ENOMEM;

client is a pointer, so

	if (client == NULL)

or

if (!client)

drivers/media/video/tlv320aic23b.c line 177

Quoted 1 line
drivers/media/video/tlv320aic23b.c +1 -0
+	snprintf(client->name, sizeof(client->name) - 1, "tlv320aic23b");
	snprintf(buf, sizeof(buf), ...)

is idiomatic.

drivers/media/video/tlv320aic23b.c line 217

Quoted 8 lines
drivers/media/video/tlv320aic23b.c +8 -0
+static int tlv320aic23b_detach(struct i2c_client *client)
+{
+	int err;
+
+	err = i2c_detach_client(client);
+	if (err) {
+		return err;
+	}

Preferred style is

	if (err)
		return err;

drivers/media/video/tlv320aic23b.mod.c

Quoted 4 lines

diff -Nupr -X dontdiff linux-2.6.16-gentoo-r1/drivers/media/video/tlv320aic23b.mod.c linux-2.6.16-gentoo-r1/drivers/media/video/tlv320aic23b.mod.c

drivers/media/video/tlv320aic23b.mod.c +0 -0

This file is generated and you have outdated dontdiff. Use "-X Documentation/dontdiff".

#3 lore raw
In reply to Scott Alfter
Quoted 9 lines · Scott Alfter

It took a little bit longer than I thought, but the attached patch adds a driver for the TI TLV320AIC23B audio codec. It implements analog audio capture at 32, 44.1, and 48 kHz (16-bit stereo). The hardware is capable of more (it supports more sample rates and includes analog output), but in its current form, the driver works well with ivtv.

Quoted 8 lines

The patch is attached; a test mailing indicated that Thunderbird attaches patches inline instead of encoded. The patch is also available from this URL:

http://alfter.us/files/linux-2.6.16-tlv320aic23b.patch

Scott Alfter
[email protected]

Hi Scott,

I've taken a quick look and I noticed a few things: first of all I recommend making a patch against the v4l-dvb repository as there have been a few changes compared to 2.6.16 that are relevant. In particular your device should start supporting VIDIOC_INT_G/S_AUDIO_ROUTING commands instead of VIDIOC_G/S_AUDIO. See the definition of these commands in v4l2-common.h for more info. This also implies that a media/tlv320aic23b.h header should be added (look at the existing headers such as wm8775.h).

I also noticed what seems to be a superfluous TODO in the VIDIOC_INT_AUDIO_CLOCK_FREQ implementation.

The enum (R7, R11, etc) isn't used and can be removed.

The input field of struct tlv320aic23b_state doesn't seem to be used, so that too can be removed.

You probably do not have to implement the VIDIOC_S_FREQUENCY command, that was wm8775 specific. I doubt it is necessary for this driver.

It is also a good idea to add support for older kernels to this driver (again, see the #if lines in the wm8775.c driver).

Hmm, well that seems to be it.

Thanks!

Hans

#2 lore raw
In reply to Alexey Dobriyan
Quoted 7 lines · Alexey Dobriyan

drivers/media/video/tlv320aic23b.c line 177

Quoted 1 line · Scott Alfter
drivers/media/video/tlv320aic23b.c +1 -0
+	snprintf(client->name, sizeof(client->name) - 1, "tlv320aic23b");
	snprintf(buf, sizeof(buf), ...)

is idiomatic.

better use strlcpy()

Johannes