public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [linux-dvb] [PATCH] cx23885 analog TV and audio support for HVR-1500
@ 2008-08-29 21:01 Tim Lucas
  2008-08-29 21:56 ` Steven Toth
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Tim Lucas @ 2008-08-29 21:01 UTC (permalink / raw)
  To: linux-dvb


[-- Attachment #1.1: Type: text/plain, Size: 2767 bytes --]

Mijhail Moreyra wrote:
> Steven Toth wrote:
>> Mijhail Moreyra wrote:
>>> Steven Toth wrote:
>>>> Mijhail,
>>>>
>>>> http://linuxtv.org/hg/~stoth/cx23885-audio<http://linuxtv.org/hg/%7Estoth/cx23885-audio>
>>>>
>>>> This tree contains your patch with some minor whitespace cleanups
>>>> and fixes for HUNK related merge issues due to the patch wrapping at
>>>> 80 cols.
>>>>
>>>> Please build this tree and retest in your environment to ensure I
>>>> did not break anything. Does this tree still work OK for you?
>>>>
>>>> After this I will apply some other minor cleanups then invite a few
>>>> other HVR1500 owners to begin testing.
>>>>
>>>> Thanks again.
>>>>
>>>> Regards,
>>>>
>>>> Steve
>>>
>>> Hi, sorry for the delay.
>>>
>>> I've tested the http://linuxtv.org/hg/~stoth/cx23885-audio<http://linuxtv.org/hg/%7Estoth/cx23885-audio>tree and
>>> it doesn't work well.
>>>
>>> You seem to have removed a piece from my patch that avoids some register
>>> modification in cx25840-core.c:cx23885_initialize()
>>>
>>> -       cx25840_write(client, 0x2, 0x76);
>>> +       if (state->rev != 0x0000) /* FIXME: How to detect the bridge
>>> type ??? */
>>> +               /* This causes image distortion on a true cx23885
>>> board */
>>> +               cx25840_write(client, 0x2, 0x76);
>>>
>>> As the patch says that register write causes a horrible image distortion
>>> on my HVR-1500 which has a real cx23885 (not 23887, 23888, etc) board.
>>>
>>> I don't know if it's really required for any bridge as everything seems
>>> to be auto-configured by default, maybe it can be simply dropped.
>>>
>>> Other than that the cx23885-audio tree works well.
>>>
>>> WRT the whitespaces, 80 cols, etc; most are also in the sources I took
>>> as basis, so I didn't think they were a problem.
>>
>> That's a mistake, I'll add that later tonight, thanks for finding
>> this. I must of missed it when I had to tear apart your email because
>> of HUNK issues caused by patch line wrapping.
>>
>> Apart from this, is everything working as you expect?
>>
>> Regards,
>>
>> Steve
>>
>>
>
> OK.
>
> And sorry about the patch, I didn't know it was going to be broken that
> way by being sent by email.
>
>  >> Other than that the cx23885-audio tree works well.
>

> Great, thanks for confirming.

> Regards,

> Steve

I'll try asking again since my replies in gmail were not including the
correct subject heading.
Can this code for cx23885 analog support be adapted for the DViCO Fusion
HDTV7 Dual Express which also uses the cx23885?  Currently the driver for
that card is digital only and I am stuck with a free antiquated large
satellite system that is analog only in my apartment. I am willing to put in
the work if someone can point me in the right direction.  Thank you,

--Tim

[-- Attachment #1.2: Type: text/html, Size: 3960 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: [linux-dvb] [PATCH] cx23885 analog TV and audio support for HVR-1500
@ 2008-09-05 14:31 Tim Lucas
  2008-09-06 21:24 ` Tim Lucas
  0 siblings, 1 reply; 28+ messages in thread
From: Tim Lucas @ 2008-09-05 14:31 UTC (permalink / raw)
  To: Steven Toth, linux dvb


[-- Attachment #1.1: Type: text/plain, Size: 6992 bytes --]

> Why doesn't the driver load if you force it with card=X? What does dmesg
show?
>
> - Steve

I followed your instructions modprobe cx23885 debug=1 says operation not
permitted
Then I tried sudo modprobe cx23885 debug=1 and it says the process was
killed
This is the output from dmeg.

589.243831] cx23885: no version for "snd_pcm_new" found: kernel tainted.
[  589.245284] cx23885 driver version 0.0.1 loaded
[  589.245628] ACPI: PCI Interrupt Link [APC6] enabled at IRQ 16
[  589.245632] ACPI: PCI Interrupt 0000:08:00.0[A] -> Link [APC6] -> GSI 16
(level, low) -> IRQ 16
[  589.245750] cx23885[0]/0: cx23885_dev_setup() Memory configured for PCIe
bridge type 885
[  589.245752] cx23885[0]/0: cx23885_init_tsport(portno=2)
[  589.245759] CORE cx23885[0]: subsystem: 18ac:d618, board: Hauppauge
WinTV-HVR1500 [card=6,insmod option]
[  589.245761] cx23885[0]/0: cx23885_pci_quirks()
[  589.245763] cx23885[0]/0: cx23885_dev_setup() tuner_type = 0x47
tuner_addr = 0x61
[  589.245765] cx23885[0]/0: cx23885_dev_setup() radio_type = 0x0 radio_addr
= 0x0
[  589.245766] cx23885[0]/0: cx23885_reset()
[  589.345825] cx23885[0]/0: cx23885_sram_channel_setup() Configuring
channel [VID A]
[  589.345837] cx23885[0]/0: cx23885_sram_channel_setup() Erasing channel
[ch2]
[  589.345838] cx23885[0]/0: cx23885_sram_channel_setup() Configuring
channel [TS1 B]
[  589.345850] cx23885[0]/0: cx23885_sram_channel_setup() Erasing channel
[ch4]
[  589.345852] cx23885[0]/0: cx23885_sram_channel_setup() Erasing channel
[ch5]
[  589.345853] cx23885[0]/0: cx23885_sram_channel_setup() Configuring
channel [TS2 C]
589.345866] cx23885[0]/0: cx23885_sram_channel_setup() Configuring channel
[TV Audio]
[  589.345880] cx23885[0]/0: cx23885_sram_channel_setup() Erasing channel
[ch8]
[  589.345882] cx23885[0]/0: cx23885_sram_channel_setup() Erasing channel
[ch9]
[  589.355776] cx23885[0]: i2c bus 0 registered
[  589.355793] cx23885[0]: i2c bus 1 registered
[  589.355810] cx23885[0]: i2c bus 2 registered
[  589.382427] tveeprom 5-0050: Encountered bad packet header [ff]. Corrupt
or not a Hauppauge eeprom.
[  589.382431] cx23885[0]: warning: unknown hauppauge model #0
[  589.382432] cx23885[0]: hauppauge eeprom: model=0
[  589.388510] cx25840' 7-0044: cx25  0-21 found @ 0x88 (cx23885[0])
[  589.395552] tuner' 5-0064: chip found @ 0xc8 (cx23885[0])
[  589.398231] tuner' 6-0064: chip found @ 0xc8 (cx23885[0])
[  589.400298] cx23885[0]/0: registered device video0 [v4l2]
[  589.400351] Unable to handle kernel NULL pointer dereference at
0000000000000008 RIP:
[  589.400353]  [<ffffffff881f5f89>] :snd:snd_device_new+0x59/0xb0
[  589.400363] PGD 7105a067 PUD 7c727067 PMD 0
[  589.400366] Oops: 0002 [1] SMP
[  589.400368] CPU 0
[  589.400369] Modules linked in: tuner cx25840 cx23885(F) af_packet ipv6
cpufreq_ondemand cpufreq_stats cpuf
q_userspace freq_table cpufreq_powersave cpufreq_conservative video output
container dock sbs sbshc battery ipt
able_filter ip_tables x_tables ac sbp2 lp compat_ioctl32 nvidia(P) videodev
v4l1_compat cx2341x videobuf_dma_sg
 v4l2_common btcx_risc tveeprom videobuf_dvb dvb_core videobuf_core
snd_hda_intel snd_pcm_oss snd_mixer_oss snd
_pcm snd_page_alloc snd_hwdep snd_seq_dummy snd_seq_oss snd_seq_midi
snd_rawmidi snd_seq_midi_event snd_seq ser
io_raw snd_timer snd_seq_device psmouse snd button i2c_nforce2 i2c_core
parport_pc parport shpchp pci_hotplug e
vdev soundcore pcspkr ext3 jbd mbcache usbhid hid sd_mod sg sr_mod cdrom
sata_nv ehci_hcd ohci1394 ohci_hcd pat
a_acpi pata_amd usbcore ieee1394 forcedeth ata_generic libata scsi_mod
thermal processor fan fbcon tileblit fon
t bitblit softcursor fuse
[  589.400408] Pid: 17811, comm: modprobe Tainted: PF
2.6.24-21-generic #1
[  589.400409] RIP: 0010:[<ffffffff881f5f89>]  [<ffffffff881f5f89>]
:snd:snd_device_new+0x59/0xb0
[  589.400416] RSP: 0018:ffff810073235aa8  EFLAGS: 00010282
[  589.400417] RAX: 0000000000000000 RBX: ffffffff88c7dd20 RCX:
0000000000000000
[  589.400418] RDX: ffff810071048e40 RSI: 0000000000000000 RDI:
ffff810071048e80
[  589.400420] RBP: 0000000000001003 R08: 0000000000000000 R09:
ffff810071048e40
[  589.400421] R10: 0000000000000000 R11: ffffffff803bcc30 R12:
ffff81007212d000
[  589.400423] R13: ffffffff8821a620 R14: ffff810073235b20 R15:
ffffffff88265e48
[  589.400424] FS:  00007f379fe496e0(0000) GS:ffffffff805b9000(0000)
knlGS:0000000000000000
[  589.400426] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  589.400427] CR2: 0000000000000008 CR3: 0000000073137000 CR4:
00000000000006e0
[  589.400429] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
0000000000000000
[  589.400430] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7:
0000000000000400
[  589.400432] Process modprobe (pid: 17811, threadinfo ffff810073234000,
task ffff81007c53c7e0)
[  589.400433] Stack:  ffff81007212d000 ffff81007212d000 ffff810073235b08
ffffffff88c7dd20
[  589.400436]  ffffffff88266648 ffffffff88215128 ffff81007b6d1e58
ffff81007212d400
[  589.400439]  0000000000000018 ffff81007212d458 0000000000000001
ffffffff88264c12
[  589.400441] Call Trace:
[  589.400448]  [<ffffffff88215128>] :snd_timer:snd_timer_new+0x128/0x180
[  589.400457]  [<ffffffff88264c12>] :snd_pcm:snd_pcm_timer_init+0x52/0x1a0
[  589.400465]  [<ffffffff8825b7dd>]
:snd_pcm:snd_pcm_dev_register+0xfd/0x220
[  589.400470]  [<ffffffff802f88a8>] create_proc_entry+0x58/0xa0
[  589.400480]  [<ffffffff881f5c9f>] :snd:snd_device_register_all+0x2f/0x60
[  589.400487]  [<ffffffff881f0b8b>] :snd:snd_card_register+0x3b/0x390
[  589.400493]  [<ffffffff8825b9e3>] :snd_pcm:snd_pcm_new+0xe3/0x140
[  589.400505]  [<ffffffff88c6f306>]
:cx23885:cx23885_audio_initdev+0x156/0x1d0
[  589.400512]  [<ffffffff88c66a52>]
:cx23885:cx23885_video_register+0x1d2/0x2f0
[  589.400520]  [<ffffffff88c644d0>]
:cx23885:cx23885_tuner_callback+0x0/0xf0
[  589.400526]  [<ffffffff881e1f8a>] :i2c_core:i2c_clients_command+0x2a/0xe0
[  589.400534]  [<ffffffff88c6aef7>] :cx23885:cx23885_initdev+0x927/0xb00
[  589.400537]  [<ffffffff8034a172>] kobject_get+0x12/0x20
[  589.400542]  [<ffffffff8035e4b8>] pci_device_probe+0xf8/0x170
[  589.400548]  [<ffffffff803bfd7c>] driver_probe_device+0x9c/0x1b0
[  589.400552]  [<ffffffff803c0049>] __driver_attach+0xc9/0xd0
[  589.400556]  [<ffffffff803bff80>] __driver_attach+0x0/0xd0
[  589.400558]  [<ffffffff803befbd>] bus_for_each_dev+0x4d/0x80
[  589.400564]  [<ffffffff803bf3cc>] bus_add_driver+0xac/0x220
[  589.400567]  [<ffffffff8035e739>] __pci_register_driver+0x69/0xb0
[  589.400572]  [<ffffffff80263e0e>] sys_init_module+0x18e/0x1a90
[  589.400586]  [<ffffffff882f2550>]
:videobuf_core:videobuf_mmap_free+0x0/0x40
[  589.400593]  [<ffffffff8020c37e>] system_call+0x7e/0x83
[  589.400600]
[  589.400600]
[  589.400601] Code: 48 89 50 08 48 89 02 48 8d 83 50 01 00 00 48 89 93 50
01 00
[  589.400607] RIP  [<ffffffff881f5f89>] :snd:snd_device_new+0x59/0xb0
[  589.400613]  RSP <ffff810073235aa8>
[  589.400614] CR2: 0000000000000008
[  589.400615] ---[ end trace 5a3db5147eff6869 ]---

-- 
--Tim

[-- Attachment #1.2: Type: text/html, Size: 8687 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: [linux-dvb] [PATCH] cx23885 analog TV and audio support for HVR-1500
@ 2008-09-04 23:25 Tim Lucas
  2008-09-05 13:22 ` Steven Toth
  0 siblings, 1 reply; 28+ messages in thread
From: Tim Lucas @ 2008-09-04 23:25 UTC (permalink / raw)
  To: stoth, linux dvb


[-- Attachment #1.1: Type: text/plain, Size: 1955 bytes --]

> Tim Lucas wrote:
>
>> For some reason, when I  add the line
>> options cx23885 card=6
>> I can no longer boot the machine successfully.
>> The machine hangs saying that
>>
>> (Ctl-alt-F1)
>> kinit: No resume image, doing normal boot . . .
>> (Ctl-alt-F8)
>> udevd-event[3374]: run-program: '/sbin/modprobe' abnormal exit
>>
>> After a while it continues to boot, but the messages go by so fast that I
>> can't read them.  Finally, it just sits on a blank screen.  Since
2.6.24-19
>> was originally installed and it updated to 2.6.24-21, I am able to boot
into
>> the older kernel and then comment out that line.
>>
>> I am pretty sure that HVR1500 is card 6, so I am not sure what is wrong.
>>  I didn't have that problem, the first time I rebooted, but have had that
>> problem on every succesive reboot.
>>
>> Any ideas?
>>
>
> Please cc the list in all email, which I've done.
>
> Check the /var/log/messages or kern.log files to see what they contain.
>
> Or, if the system isn't booting, remove the module from your
> /lib/modules/`uname -r`/kernel/drivers/media/video/cx23885 dir then boot
> again.
>
> The card won't get initialised by the driver won't exist, then you can
> install the driver with 'make install' which will install it from your
> linux-dvb/v4l test tree, then load it at your own leisure with modprobe
> cx23885 debug=1.
>
>
> - Steve
>

Using your instructions, I figured out that the driver will not load using
modprobe. That is why the computer has trouble booting with that driver and
the HVR-1500 card selected.I also tried copying the relevant code and
putting it into the DViCO FusionHDTV7 Dual Express area to see if that
worked. I had the same results as when I tried loading the card as a
HVR-1500. I cannot get any signal from the card that way.  I know the card
is getting a signal because it shows a signal when loaded as a digital card.
 If you have any suggestions I would appreciate them.  Thank you.

-- 
--Tim

[-- Attachment #1.2: Type: text/html, Size: 2590 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 28+ messages in thread
* [linux-dvb] [PATCH] cx23885 analog TV and audio support for HVR-1500
@ 2008-08-26 20:33 Mijhail Moreyra
  2008-08-26 20:53 ` Steven Toth
  0 siblings, 1 reply; 28+ messages in thread
From: Mijhail Moreyra @ 2008-08-26 20:33 UTC (permalink / raw)
  To: linux-dvb

Hi,

This patch adds analog TV support for the HVR-1500 which has a cx23885 
bridge and a xc3028 tuner but no MPEG encoder. It also adds support for 
ALSA audio capture.

There isn't digital TV in my country so I didn't test if it breaks 
digital mode.

Hope it will be useful for anyone interested.

Regards.
Mijhail Moreyra

-----------------------------------------------------------------------

diff -uprN old/linux/drivers/media/video/cx23885/cx23885-alsa.c 
new/linux/drivers/media/video/cx23885/cx23885-alsa.c
--- old/linux/drivers/media/video/cx23885/cx23885-alsa.c	1969-12-31 
19:00:00.000000000 -0500
+++ new/linux/drivers/media/video/cx23885/cx23885-alsa.c	2008-08-26 
15:00:38.386185324 -0500
@@ -0,0 +1,533 @@
+/*
+ *
+ *  Support for CX23885 analog audio capture
+ *
+ *    (c) 2008 Mijhail Moreyra <mijhail.moreyra@gmail.com>
+ *    Adapted from cx88-alsa.c
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <linux/vmalloc.h>
+#include <linux/dma-mapping.h>
+#include <linux/pci.h>
+
+#include <asm/delay.h>
+#include "compat.h"
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/control.h>
+#include <sound/initval.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+#include <sound/tlv.h>
+#endif
+
+#include "cx23885.h"
+#include "cx23885-reg.h"
+
+#define AUDIO_SRAM_CHANNEL	SRAM_CH07
+
+#define dprintk(level, fmt, arg...)	if (audio_debug >= level) \
+	printk(KERN_INFO "%s/1: " fmt, chip->dev->name , ## arg)
+
+#define dprintk_core(level, fmt, arg...)	if (audio_debug >= level) \
+	printk(KERN_DEBUG "%s/1: " fmt, chip->dev->name , ## arg)
+
+/****************************************************************************
+			Module global static vars
+ 
****************************************************************************/
+
+static unsigned int disable_analog_audio;
+module_param(disable_analog_audio, int, 0644);
+MODULE_PARM_DESC(disable_analog_audio, "disable analog audio ALSA driver");
+
+static unsigned int audio_debug;
+module_param(audio_debug, int, 0644);
+MODULE_PARM_DESC(audio_debug, "enable debug messages [analog audio]");
+
+/****************************************************************************
+			Board specific funtions
+ 
****************************************************************************/
+
+/* Constants taken from cx88-reg.h */
+#define AUD_INT_DN_RISCI1       (1 <<  0)
+#define AUD_INT_UP_RISCI1       (1 <<  1)
+#define AUD_INT_RDS_DN_RISCI1   (1 <<  2)
+#define AUD_INT_DN_RISCI2       (1 <<  4) /* yes, 3 is skipped */
+#define AUD_INT_UP_RISCI2       (1 <<  5)
+#define AUD_INT_RDS_DN_RISCI2   (1 <<  6)
+#define AUD_INT_DN_SYNC         (1 << 12)
+#define AUD_INT_UP_SYNC         (1 << 13)
+#define AUD_INT_RDS_DN_SYNC     (1 << 14)
+#define AUD_INT_OPC_ERR         (1 << 16)
+#define AUD_INT_BER_IRQ         (1 << 20)
+#define AUD_INT_MCHG_IRQ        (1 << 21)
+#define GP_COUNT_CONTROL_RESET	0x3
+
+/*
+ * BOARD Specific: Sets audio DMA
+ */
+
+static int cx23885_start_audio_dma(struct cx23885_audio_dev *chip)
+{
+	struct cx23885_buffer *buf = chip->buf;
+	struct cx23885_dev *dev  = chip->dev;
+	struct sram_channel *audio_ch = &dev->sram_channels[AUDIO_SRAM_CHANNEL];
+
+	dprintk(1, "%s()\n", __func__);
+
+	/* Make sure RISC/FIFO are off before changing FIFO/RISC settings */
+	cx_clear(AUD_INT_DMA_CTL, 0x11);
+
+	/* setup fifo + format - out channel */
+	cx23885_sram_channel_setup(chip->dev, audio_ch, buf->bpl, buf->risc.dma);
+
+	/* sets bpl size */
+	cx_write(AUD_INT_A_LNGTH, buf->bpl);
+
+	/* This is required to get good audio (1 seems to be ok) */
+	cx_write(AUD_INT_A_MODE, 1);
+
+	/* reset counter */
+	cx_write(AUD_INT_A_GPCNT_CTL, GP_COUNT_CONTROL_RESET);
+	atomic_set(&chip->count, 0);
+
+	dprintk(1, "Start audio DMA, %d B/line, %d lines/FIFO, %d periods, %d "
+		"byte buffer\n", buf->bpl, cx_read(audio_ch->cmds_start+12)>>1,
+		chip->num_periods, buf->bpl * chip->num_periods);
+
+	/* Enables corresponding bits at AUD_INT_STAT */
+	cx_write(AUDIO_INT_INT_MSK, AUD_INT_OPC_ERR | AUD_INT_DN_SYNC |
+				    AUD_INT_DN_RISCI1);
+
+	/* Clean any pending interrupt bits already set */
+	cx_write(AUDIO_INT_INT_STAT, ~0);
+
+	/* enable audio irqs */
+	cx_set(PCI_INT_MSK, chip->dev->pci_irqmask | PCI_MSK_AUD_INT);
+
+	/* start dma */
+	cx_set(DEV_CNTRL2, (1<<5)); /* Enables Risc Processor */
+	cx_set(AUD_INT_DMA_CTL, 0x11); /* audio downstream FIFO and
+					  RISC enable */
+	if (audio_debug)
+		cx23885_sram_channel_dump(chip->dev, audio_ch);
+
+	return 0;
+}
+
+/*
+ * BOARD Specific: Resets audio DMA
+ */
+static int cx23885_stop_audio_dma(struct cx23885_audio_dev *chip)
+{
+	struct cx23885_dev *dev = chip->dev;
+	dprintk(1, "Stopping audio DMA\n");
+
+	/* stop dma */
+	cx_clear(AUD_INT_DMA_CTL, 0x11);
+
+	/* disable irqs */
+	cx_clear(PCI_INT_MSK, PCI_MSK_AUD_INT);
+	cx_clear(AUDIO_INT_INT_MSK, AUD_INT_OPC_ERR | AUD_INT_DN_SYNC |
+				    AUD_INT_DN_RISCI1);
+
+	if (audio_debug)
+		cx23885_sram_channel_dump(chip->dev,
+			&dev->sram_channels[AUDIO_SRAM_CHANNEL]);
+
+	return 0;
+}
+
+/*
+ * BOARD Specific: Handles audio IRQ
+ */
+int cx23885_audio_irq(struct cx23885_dev *dev, u32 status, u32 mask)
+{
+	struct cx23885_audio_dev *chip = dev->audio_dev;
+
+	if (0 == (status & mask))
+		return 0;
+
+	cx_write(AUDIO_INT_INT_STAT, status);
+
+	/* risc op code error */
+	if (status & AUD_INT_OPC_ERR) {
+		printk(KERN_WARNING "%s/1: Audio risc op code error\n",	dev->name);
+		cx_clear(AUD_INT_DMA_CTL, 0x11);
+		cx23885_sram_channel_dump(dev,
+			&dev->sram_channels[AUDIO_SRAM_CHANNEL]);
+	}
+	if (status & AUD_INT_DN_SYNC) {
+		dprintk(1, "Downstream sync error\n");
+		cx_write(AUD_INT_A_GPCNT_CTL, GP_COUNT_CONTROL_RESET);
+		return 1;
+	}
+	/* risc1 downstream */
+	if (status & AUD_INT_DN_RISCI1) {
+		atomic_set(&chip->count, cx_read(AUD_INT_A_GPCNT));
+		snd_pcm_period_elapsed(chip->substream);
+	}
+	/* FIXME: Any other status should deserve a special handling? */
+
+	return 1;
+}
+
+static int dsp_buffer_free(struct cx23885_audio_dev *chip)
+{
+	BUG_ON(!chip->dma_size);
+
+	dprintk(2, "Freeing buffer\n");
+	videobuf_sg_dma_unmap(&chip->pci->dev, chip->dma_risc);
+	videobuf_dma_free(chip->dma_risc);
+	btcx_riscmem_free(chip->pci, &chip->buf->risc);
+	kfree(chip->buf);
+
+	chip->dma_risc = NULL;
+	chip->dma_size = 0;
+
+	return 0;
+}
+
+/****************************************************************************
+				ALSA PCM Interface
+ 
****************************************************************************/
+
+/*
+ * Digital hardware definition
+ */
+#define DEFAULT_FIFO_SIZE	4096
+
+static struct snd_pcm_hardware snd_cx23885_digital_hw = {
+	.info = SNDRV_PCM_INFO_MMAP |
+		SNDRV_PCM_INFO_INTERLEAVED |
+		SNDRV_PCM_INFO_BLOCK_TRANSFER |
+		SNDRV_PCM_INFO_MMAP_VALID,
+	.formats = SNDRV_PCM_FMTBIT_S16_LE,
+
+	.rates =		SNDRV_PCM_RATE_48000,
+	.rate_min =		48000,
+	.rate_max =		48000,
+	.channels_min = 2,
+	.channels_max = 2,
+	/* Analog audio output will be full of clicks and pops if there
+	   are not exactly four lines in the SRAM FIFO buffer.  */
+	.period_bytes_min = DEFAULT_FIFO_SIZE/4,
+	.period_bytes_max = DEFAULT_FIFO_SIZE/4,
+	.periods_min = 1,
+	.periods_max = 1024,
+	.buffer_bytes_max = (1024*1024),
+};
+
+/*
+ * audio pcm capture open callback
+ */
+static int snd_cx23885_pcm_open(struct snd_pcm_substream *substream)
+{
+	struct cx23885_audio_dev *chip = snd_pcm_substream_chip(substream);
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	int err;
+
+	if (!chip) {
+		printk(KERN_ERR "BUG: cx23885 can't find device struct."
+				" Can't proceed with open\n");
+		return -ENODEV;
+	}
+
+	err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS);
+	if (err < 0)
+		goto _error;
+
+	chip->substream = substream;
+
+	runtime->hw = snd_cx23885_digital_hw;
+
+	if (chip->dev->sram_channels[AUDIO_SRAM_CHANNEL].fifo_size != 
DEFAULT_FIFO_SIZE) {
+		unsigned int bpl = 
chip->dev->sram_channels[AUDIO_SRAM_CHANNEL].fifo_size / 4;
+		bpl &= ~7; /* must be multiple of 8 */
+		runtime->hw.period_bytes_min = bpl;
+		runtime->hw.period_bytes_max = bpl;
+	}
+
+	return 0;
+_error:
+	dprintk(1, "Error opening PCM!\n");
+	return err;
+}
+
+/*
+ * audio close callback
+ */
+static int snd_cx23885_close(struct snd_pcm_substream *substream)
+{
+	return 0;
+}
+
+/*
+ * hw_params callback
+ */
+static int snd_cx23885_hw_params(struct snd_pcm_substream *substream,
+			      struct snd_pcm_hw_params *hw_params)
+{
+	struct cx23885_audio_dev *chip = snd_pcm_substream_chip(substream);
+	struct videobuf_dmabuf *dma;
+
+	struct cx23885_buffer *buf;
+	int ret;
+
+	if (substream->runtime->dma_area) {
+		dsp_buffer_free(chip);
+		substream->runtime->dma_area = NULL;
+	}
+
+	chip->period_size = params_period_bytes(hw_params);
+	chip->num_periods = params_periods(hw_params);
+	chip->dma_size = chip->period_size * params_periods(hw_params);
+
+	BUG_ON(!chip->dma_size);
+	BUG_ON(chip->num_periods & (chip->num_periods-1));
+
+	buf = videobuf_sg_alloc(sizeof(*buf));
+	if (NULL == buf)
+		return -ENOMEM;
+
+	buf->vb.memory = V4L2_MEMORY_MMAP;
+	buf->vb.field  = V4L2_FIELD_NONE;
+	buf->vb.width  = chip->period_size;
+	buf->bpl       = chip->period_size;
+	buf->vb.height = chip->num_periods;
+	buf->vb.size   = chip->dma_size;
+
+	dma = videobuf_to_dma(&buf->vb);
+	videobuf_dma_init(dma);
+	ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE,
+			(PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
+	if (ret < 0)
+		goto error;
+
+	ret = videobuf_sg_dma_map(&chip->pci->dev, dma);
+	if (ret < 0)
+		goto error;
+
+	ret = cx23885_risc_databuffer(chip->pci, &buf->risc, dma->sglist,
+				   buf->vb.width, buf->vb.height, 1);
+	if (ret < 0)
+		goto error;
+
+	/* Loop back to start of program */
+	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP|RISC_IRQ1|RISC_CNT_INC);
+	buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
+	buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */
+
+	buf->vb.state = VIDEOBUF_PREPARED;
+
+	chip->buf = buf;
+	chip->dma_risc = dma;
+
+	substream->runtime->dma_area = chip->dma_risc->vmalloc;
+	substream->runtime->dma_bytes = chip->dma_size;
+	substream->runtime->dma_addr = 0;
+
+	return 0;
+
+error:
+	kfree(buf);
+	return ret;
+}
+
+/*
+ * hw free callback
+ */
+static int snd_cx23885_hw_free(struct snd_pcm_substream *substream)
+{
+
+	struct cx23885_audio_dev *chip = snd_pcm_substream_chip(substream);
+
+	if (substream->runtime->dma_area) {
+		dsp_buffer_free(chip);
+		substream->runtime->dma_area = NULL;
+	}
+
+	return 0;
+}
+
+/*
+ * prepare callback
+ */
+static int snd_cx23885_prepare(struct snd_pcm_substream *substream)
+{
+	return 0;
+}
+
+/*
+ * trigger callback
+ */
+static int snd_cx23885_card_trigger(struct snd_pcm_substream 
*substream, int cmd)
+{
+	struct cx23885_audio_dev *chip = snd_pcm_substream_chip(substream);
+	int err;
+
+	/* Local interrupts are already disabled by ALSA */
+	spin_lock(&chip->reg_lock);
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+		err = cx23885_start_audio_dma(chip);
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+		err = cx23885_stop_audio_dma(chip);
+		break;
+	default:
+		err = -EINVAL;
+		break;
+	}
+
+	spin_unlock(&chip->reg_lock);
+
+	return err;
+}
+
+/*
+ * pointer callback
+ */
+static snd_pcm_uframes_t snd_cx23885_pointer(struct snd_pcm_substream 
*substream)
+{
+	struct cx23885_audio_dev *chip = snd_pcm_substream_chip(substream);
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	u16 count;
+
+	count = atomic_read(&chip->count);
+
+	return runtime->period_size * (count & (runtime->periods-1));
+}
+
+/*
+ * page callback (needed for mmap)
+ */
+static struct page *snd_cx23885_page(struct snd_pcm_substream *substream,
+				unsigned long offset)
+{
+	void *pageptr = substream->runtime->dma_area + offset;
+	return vmalloc_to_page(pageptr);
+}
+
+/*
+ * operators
+ */
+static struct snd_pcm_ops snd_cx23885_pcm_ops = {
+	.open = snd_cx23885_pcm_open,
+	.close = snd_cx23885_close,
+	.ioctl = snd_pcm_lib_ioctl,
+	.hw_params = snd_cx23885_hw_params,
+	.hw_free = snd_cx23885_hw_free,
+	.prepare = snd_cx23885_prepare,
+	.trigger = snd_cx23885_card_trigger,
+	.pointer = snd_cx23885_pointer,
+	.page = snd_cx23885_page,
+};
+
+/*
+ * create a PCM device
+ */
+static int snd_cx23885_pcm(struct cx23885_audio_dev *chip, int device, 
char *name)
+{
+	int err;
+	struct snd_pcm *pcm;
+
+	err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm);
+	if (err < 0)
+		return err;
+	pcm->private_data = chip;
+	strcpy(pcm->name, name);
+	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx23885_pcm_ops);
+
+	return 0;
+}
+
+/****************************************************************************
+			Basic Flow for Sound Devices
+ 
****************************************************************************/
+
+/*
+ * Alsa Constructor - Component probe
+ */
+
+struct cx23885_audio_dev *cx23885_audio_initdev(struct cx23885_dev *dev)
+{
+	struct snd_card *card;
+	struct cx23885_audio_dev *chip;
+	int err;
+
+	if (disable_analog_audio)
+		return NULL;
+
+	if (dev->sram_channels[AUDIO_SRAM_CHANNEL].cmds_start == 0) {
+		printk(KERN_WARNING "%s(): Missing SRAM channel configuration "
+			"for analog TV Audio\n", __func__);
+		return NULL;
+	}
+
+	card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+			    THIS_MODULE, sizeof(struct cx23885_audio_dev));
+	if (!card)
+		goto error;
+
+	chip = (struct cx23885_audio_dev *) card->private_data;
+	chip->dev = dev;
+	chip->pci = dev->pci;
+	chip->card = card;
+	spin_lock_init(&chip->reg_lock);
+
+	snd_card_set_dev(card, &dev->pci->dev);
+
+	err = snd_cx23885_pcm(chip, 0, "CX23885 Digital");
+	if (err < 0)
+		goto error;
+
+	strcpy(card->driver, "CX23885");
+	sprintf(card->shortname, "Conexant CX23885");
+	sprintf(card->longname, "%s at %s", card->shortname, dev->name);
+
+	err = snd_card_register(card);
+	if (err < 0)
+		goto error;
+
+	dprintk(0, "registered ALSA audio device\n");
+
+	return chip;
+
+error:
+	snd_card_free(card);
+	printk(KERN_ERR "%s(): Failed to register analog "
+			"audio adapter\n", __func__);
+
+	return NULL;
+}
+
+/*
+ * ALSA destructor
+ */
+void cx23885_audio_finidev(struct cx23885_dev *dev)
+{
+	struct cx23885_audio_dev *chip = dev->audio_dev;
+
+	snd_card_free(chip->card);
+}
+
diff -uprN old/linux/drivers/media/video/cx23885/cx23885-cards.c 
new/linux/drivers/media/video/cx23885/cx23885-cards.c
--- old/linux/drivers/media/video/cx23885/cx23885-cards.c	2008-08-09 
07:21:15.000000000 -0500
+++ new/linux/drivers/media/video/cx23885/cx23885-cards.c	2008-08-26 
14:40:47.316185717 -0500
@@ -131,7 +131,30 @@ struct cx23885_board cx23885_boards[] =
  	},
  	[CX23885_BOARD_HAUPPAUGE_HVR1500] = {
  		.name		= "Hauppauge WinTV-HVR1500",
+		.porta		= CX23885_ANALOG_VIDEO,
  		.portc		= CX23885_MPEG_DVB,
+		.tuner_type	= TUNER_XC2028,
+		.tuner_addr	= 0x61, /* 0xc2 >> 1 */
+		.input          = {{
+			.type   = CX23885_VMUX_TELEVISION,
+			.vmux   =	CX25840_VIN7_CH3 |
+					CX25840_VIN5_CH2 |
+					CX25840_VIN2_CH1,
+			.gpio0  = 0,
+		},{
+			.type   = CX23885_VMUX_COMPOSITE1,
+			.vmux   =	CX25840_VIN7_CH3 |
+					CX25840_VIN4_CH2 |
+					CX25840_VIN6_CH1,
+			.gpio0  = 0,
+		},{
+			.type   = CX23885_VMUX_SVIDEO,
+			.vmux   =	CX25840_VIN7_CH3 |
+					CX25840_VIN4_CH2 |
+					CX25840_VIN8_CH1 |
+					CX25840_SVIDEO_ON,
+			.gpio0  = 0,
+		}},
  	},
  	[CX23885_BOARD_HAUPPAUGE_HVR1200] = {
  		.name		= "Hauppauge WinTV-HVR1200",
@@ -592,6 +615,7 @@ void cx23885_card_setup(struct cx23885_d
  	case CX23885_BOARD_HAUPPAUGE_HVR1800:
  	case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  	case CX23885_BOARD_HAUPPAUGE_HVR1700:
+	case CX23885_BOARD_HAUPPAUGE_HVR1500:
  		request_module("cx25840");
  		break;
  	}
diff -uprN old/linux/drivers/media/video/cx23885/cx23885-core.c 
new/linux/drivers/media/video/cx23885/cx23885-core.c
--- old/linux/drivers/media/video/cx23885/cx23885-core.c	2008-08-09 
07:21:15.000000000 -0500
+++ new/linux/drivers/media/video/cx23885/cx23885-core.c	2008-08-26 
15:03:38.149188305 -0500
@@ -151,12 +151,12 @@ static struct sram_channel cx23885_sram_
  		.cnt2_reg	= DMA5_CNT2,
  	},
  	[SRAM_CH07] = {
-		.name		= "ch7",
-		.cmds_start	= 0x0,
-		.ctrl_start	= 0x0,
-		.cdt		= 0x0,
-		.fifo_start	= 0x0,
-		.fifo_size	= 0x0,
+		.name		= "TV Audio",
+		.cmds_start	= 0x10190,
+		.ctrl_start	= 0x10480,
+		.cdt		= 0x10a00,
+		.fifo_start	= 0x7000,
+		.fifo_size	= 0x1000,
  		.ptr1_reg	= DMA6_PTR1,
  		.ptr2_reg	= DMA6_PTR2,
  		.cnt1_reg	= DMA6_CNT1,
@@ -940,10 +940,10 @@ static void cx23885_dev_unregister(struc
  static __le32* cx23885_risc_field(__le32 *rp, struct scatterlist *sglist,
  			       unsigned int offset, u32 sync_line,
  			       unsigned int bpl, unsigned int padding,
-			       unsigned int lines)
+			       unsigned int lines, unsigned int lpi)
  {
  	struct scatterlist *sg;
-	unsigned int line, todo;
+	unsigned int line, todo, sol;

  	/* sync instruction */
  	if (sync_line != NO_SYNC_LINE)
@@ -956,16 +956,22 @@ static __le32* cx23885_risc_field(__le32
  			offset -= sg_dma_len(sg);
  			sg++;
  		}
+
+		if (lpi && line>0 && !(line % lpi))
+			sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC;
+		else
+			sol = RISC_SOL;
+
  		if (bpl <= sg_dma_len(sg)-offset) {
  			/* fits into current chunk */
-			*(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl);
+			*(rp++)=cpu_to_le32(RISC_WRITE|sol|RISC_EOL|bpl);
  			*(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
  			*(rp++)=cpu_to_le32(0); /* bits 63-32 */
  			offset+=bpl;
  		} else {
  			/* scanline needs to be split */
  			todo = bpl;
-			*(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL|
+			*(rp++)=cpu_to_le32(RISC_WRITE|sol|
  					    (sg_dma_len(sg)-offset));
  			*(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
  			*(rp++)=cpu_to_le32(0); /* bits 63-32 */
@@ -1020,10 +1026,10 @@ int cx23885_risc_buffer(struct pci_dev *
  	rp = risc->cpu;
  	if (UNSET != top_offset)
  		rp = cx23885_risc_field(rp, sglist, top_offset, 0,
-					bpl, padding, lines);
+					bpl, padding, lines, 0);
  	if (UNSET != bottom_offset)
  		rp = cx23885_risc_field(rp, sglist, bottom_offset, 0x200,
-					bpl, padding, lines);
+					bpl, padding, lines, 0);

  	/* save pointer to jmp instruction address */
  	risc->jmp = rp;
@@ -1031,11 +1037,12 @@ int cx23885_risc_buffer(struct pci_dev *
  	return 0;
  }

-static int cx23885_risc_databuffer(struct pci_dev *pci,
+int cx23885_risc_databuffer(struct pci_dev *pci,
  				   struct btcx_riscmem *risc,
  				   struct scatterlist *sglist,
  				   unsigned int bpl,
-				   unsigned int lines)
+				   unsigned int lines,
+				   unsigned int lpi)
  {
  	u32 instructions;
  	__le32 *rp;
@@ -1054,7 +1061,7 @@ static int cx23885_risc_databuffer(struc

  	/* write risc instructions */
  	rp = risc->cpu;
-	rp = cx23885_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines);
+	rp = cx23885_risc_field(rp, sglist, 0, NO_SYNC_LINE, bpl, 0, lines, lpi);

  	/* save pointer to jmp instruction address */
  	risc->jmp = rp;
@@ -1373,7 +1380,7 @@ int cx23885_buf_prepare(struct videobuf_
  			goto fail;
  		cx23885_risc_databuffer(dev->pci, &buf->risc,
  					videobuf_to_dma(&buf->vb)->sglist,
-					buf->vb.width, buf->vb.height);
+					buf->vb.width, buf->vb.height, 0);
  	}
  	buf->vb.state = VIDEOBUF_PREPARED;
  	return 0;
@@ -1593,14 +1600,17 @@ static irqreturn_t cx23885_irq(int irq,
  	struct cx23885_tsport *ts2 = &dev->ts2;
  	u32 pci_status, pci_mask;
  	u32 vida_status, vida_mask;
+	u32 audint_status, audint_mask;
  	u32 ts1_status, ts1_mask;
  	u32 ts2_status, ts2_mask;
-	int vida_count = 0, ts1_count = 0, ts2_count = 0, handled = 0;
+	int vida_count = 0, audint_count = 0, ts1_count = 0, ts2_count = 0, 
handled = 0;

  	pci_status = cx_read(PCI_INT_STAT);
  	pci_mask = cx_read(PCI_INT_MSK);
  	vida_status = cx_read(VID_A_INT_STAT);
  	vida_mask = cx_read(VID_A_INT_MSK);
+	audint_status = cx_read(AUDIO_INT_INT_STAT);
+	audint_mask = cx_read(AUDIO_INT_INT_MSK);
  	ts1_status = cx_read(VID_B_INT_STAT);
  	ts1_mask = cx_read(VID_B_INT_MSK);
  	ts2_status = cx_read(VID_C_INT_STAT);
@@ -1610,12 +1620,15 @@ static irqreturn_t cx23885_irq(int irq,
  		goto out;

  	vida_count = cx_read(VID_A_GPCNT);
+	audint_count = cx_read(AUD_INT_A_GPCNT);
  	ts1_count = cx_read(ts1->reg_gpcnt);
  	ts2_count = cx_read(ts2->reg_gpcnt);
  	dprintk(7, "pci_status: 0x%08x  pci_mask: 0x%08x\n",
  		pci_status, pci_mask);
  	dprintk(7, "vida_status: 0x%08x vida_mask: 0x%08x count: 0x%x\n",
  		vida_status, vida_mask, vida_count);
+	dprintk(7, "audint_status: 0x%08x audint_mask: 0x%08x count: 0x%x\n",
+		audint_status, audint_mask, audint_count);
  	dprintk(7, "ts1_status: 0x%08x  ts1_mask: 0x%08x count: 0x%x\n",
  		ts1_status, ts1_mask, ts1_count);
  	dprintk(7, "ts2_status: 0x%08x  ts2_mask: 0x%08x count: 0x%x\n",
@@ -1675,6 +1688,9 @@ static irqreturn_t cx23885_irq(int irq,
  	if (vida_status)
  		handled += cx23885_video_irq(dev, vida_status);

+	if (audint_status)
+		handled += cx23885_audio_irq(dev, audint_status, audint_mask);
+
  	if (handled)
  		cx_write(PCI_INT_STAT, pci_status);
  out:
diff -uprN old/linux/drivers/media/video/cx23885/cx23885.h 
new/linux/drivers/media/video/cx23885/cx23885.h
--- old/linux/drivers/media/video/cx23885/cx23885.h	2008-08-09 
07:21:15.000000000 -0500
+++ new/linux/drivers/media/video/cx23885/cx23885.h	2008-08-26 
14:40:47.318185412 -0500
@@ -264,6 +264,27 @@ struct cx23885_tsport {
  	u32                        hw_sop_ctrl_val;
  };

+struct cx23885_audio_dev {
+	struct cx23885_dev            *dev;
+
+	struct pci_dev             *pci;
+
+	struct snd_card            *card;
+
+	spinlock_t                 reg_lock;
+	atomic_t                   count;
+
+	unsigned int               dma_size;
+	unsigned int               period_size;
+	unsigned int               num_periods;
+
+	struct videobuf_dmabuf     *dma_risc;
+
+	struct cx23885_buffer      *buf;
+
+	struct snd_pcm_substream   *substream;
+};
+
  struct cx23885_dev {
  	struct list_head           devlist;
  	atomic_t                   refcount;
@@ -313,6 +334,9 @@ struct cx23885_dev {
  	unsigned char              radio_addr;
  	unsigned int               has_radio;

+	/* Analog audio */
+	struct cx23885_audio_dev   *audio_dev;
+
  	/* V4l */
  	u32                        freq;
  	struct video_device        *video_dev;
@@ -394,6 +418,13 @@ extern int cx23885_risc_buffer(struct pc
  	unsigned int top_offset, unsigned int bottom_offset,
  	unsigned int bpl, unsigned int padding, unsigned int lines);

+extern int cx23885_risc_databuffer(struct pci_dev *pci,
+				   struct btcx_riscmem *risc,
+				   struct scatterlist *sglist,
+				   unsigned int bpl,
+				   unsigned int lines,
+				   unsigned int lpi);
+
  void cx23885_cancel_buffers(struct cx23885_tsport *port);

  extern int cx23885_restart_queue(struct cx23885_tsport *port,
@@ -438,6 +469,13 @@ extern void cx23885_video_unregister(str
  extern int cx23885_video_irq(struct cx23885_dev *dev, u32 status);

  /* ----------------------------------------------------------- */
+/* cx23885-alsa.c                                             */
+/* Analog audio */
+extern struct cx23885_audio_dev *cx23885_audio_initdev(struct 
cx23885_dev *dev);
+extern void cx23885_audio_finidev(struct cx23885_dev *dev);
+extern int cx23885_audio_irq(struct cx23885_dev *dev, u32 status, u32 
mask);
+
+/* ----------------------------------------------------------- */
  /* cx23885-vbi.c                                               */
  extern int cx23885_vbi_fmt(struct file *file, void *priv,
  	struct v4l2_format *f);
diff -uprN old/linux/drivers/media/video/cx23885/cx23885-video.c 
new/linux/drivers/media/video/cx23885/cx23885-video.c
--- old/linux/drivers/media/video/cx23885/cx23885-video.c	2008-08-09 
07:21:15.000000000 -0500
+++ new/linux/drivers/media/video/cx23885/cx23885-video.c	2008-08-26 
14:40:47.319185469 -0500
@@ -36,6 +36,9 @@
  #include <media/v4l2-common.h>
  #include <media/v4l2-ioctl.h>

+#include "tuner-xc2028.h"
+#include <media/cx25840.h>
+
  #ifdef CONFIG_VIDEO_V4L1_COMPAT
  /* Include V4L1 specific functions. Should be removed soon */
  #include <linux/videodev.h>
@@ -206,7 +209,7 @@ static struct cx23885_ctrl cx23885_ctls[
  			.id            = V4L2_CID_CONTRAST,
  			.name          = "Contrast",
  			.minimum       = 0,
-			.maximum       = 0xff,
+			.maximum       = 0x7f,
  			.step          = 1,
  			.default_value = 0x3f,
  			.type          = V4L2_CTRL_TYPE_INTEGER,
@@ -219,10 +222,10 @@ static struct cx23885_ctrl cx23885_ctls[
  		.v = {
  			.id            = V4L2_CID_HUE,
  			.name          = "Hue",
-			.minimum       = 0,
-			.maximum       = 0xff,
+			.minimum       = -127,
+			.maximum       = 127,
  			.step          = 1,
-			.default_value = 0x7f,
+			.default_value = 0,
  			.type          = V4L2_CTRL_TYPE_INTEGER,
  		},
  		.off                   = 128,
@@ -237,9 +240,9 @@ static struct cx23885_ctrl cx23885_ctls[
  			.id            = V4L2_CID_SATURATION,
  			.name          = "Saturation",
  			.minimum       = 0,
-			.maximum       = 0xff,
+			.maximum       = 0x7f,
  			.step          = 1,
-			.default_value = 0x7f,
+			.default_value = 0x3f,
  			.type          = V4L2_CTRL_TYPE_INTEGER,
  		},
  		.off                   = 0,
@@ -977,11 +980,8 @@ EXPORT_SYMBOL(cx23885_get_control);

  int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl)
  {
-	dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)"
-		" (disabled - no action)\n", __func__);
-#if 0
+	dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)\n", __func__);
  	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, ctl);
-#endif
  	return 0;
  }
  EXPORT_SYMBOL(cx23885_set_control);
@@ -1339,14 +1339,13 @@ static int vidioc_g_tuner(struct file *f
  	if (0 != t->index)
  		return -EINVAL;

+	memset(t, 0, sizeof(*t));
  	strcpy(t->name, "Television");
-	t->type       = V4L2_TUNER_ANALOG_TV;
-	t->capability = V4L2_TUNER_CAP_NORM;
-	t->rangehigh  = 0xffffffffUL;
-#if 0
-	cx23885_get_stereo(dev, t);
-#endif
-	t->signal = 0xffff ; /* LOCKED */
+	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t);
+	cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
+
+	dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type);
+
  	return 0;
  }

@@ -1362,6 +1361,9 @@ static int vidioc_s_tuner(struct file *f
  #if 0
  	cx23885_set_stereo(dev, t->audmode, 1);
  #endif
+	/* Update the A/V core */
+	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_TUNER, t);
+
  	return 0;
  }

@@ -1757,6 +1759,40 @@ void cx23885_video_unregister(struct cx2

  		btcx_riscmem_free(dev->pci, &dev->vidq.stopper);
  	}
+
+	if (dev->audio_dev)
+		cx23885_audio_finidev(dev);
+}
+
+static void config_analog_tuner(struct cx23885_dev *dev)
+{
+	struct tuner_setup	tun_setup;
+
+	if (dev->tuner_type == TUNER_ABSENT)
+		return;
+
+	request_module("tuner");
+
+	memset(&tun_setup, 0, sizeof(tun_setup));
+	tun_setup.mode_mask = T_ANALOG_TV;
+	tun_setup.type = dev->tuner_type;
+	tun_setup.addr = dev->tuner_addr;
+	tun_setup.tuner_callback = cx23885_tuner_callback;	/* Is this ok ??? */
+
+	cx23885_call_i2c_clients(&dev->i2c_bus[1], TUNER_SET_TYPE_ADDR, 
&tun_setup);
+
+	if (dev->tuner_type == TUNER_XC2028) {
+		struct xc2028_ctrl ctl = {
+			.fname 	 	= XC2028_DEFAULT_FIRMWARE,
+			.max_len 	= 64,
+		};
+		struct v4l2_priv_tun_config xc2028_cfg = {
+			.tuner 		= TUNER_XC2028,
+			.priv  		= &ctl,
+		};
+
+		cx23885_call_i2c_clients(&dev->i2c_bus[1], TUNER_SET_CONFIG, 
&xc2028_cfg);
+	}
  }

  int cx23885_video_register(struct cx23885_dev *dev)
@@ -1805,6 +1841,9 @@ int cx23885_video_register(struct cx2388
  		request_module("wm8775");
  #endif

+	/* Configure Analog Tuner */
+	config_analog_tuner(dev);
+
  	/* register v4l devices */
  	dev->video_dev = cx23885_vdev_init(dev, dev->pci,
  		&cx23885_video_template, "video");
@@ -1844,6 +1883,9 @@ int cx23885_video_register(struct cx2388
  		       dev->name, dev->radio_dev->minor & 0x1f);
  	}
  #endif
+	/* Register ALSA audio device */
+	dev->audio_dev = cx23885_audio_initdev(dev);
+
  	/* initial device configuration */
  	mutex_lock(&dev->lock);
  	cx23885_set_tvnorm(dev, dev->tvnorm);
diff -uprN old/linux/drivers/media/video/cx23885/Makefile 
new/linux/drivers/media/video/cx23885/Makefile
--- old/linux/drivers/media/video/cx23885/Makefile	2008-08-09 
07:21:15.000000000 -0500
+++ new/linux/drivers/media/video/cx23885/Makefile	2008-08-26 
14:40:47.319185469 -0500
@@ -1,4 +1,4 @@
-cx23885-objs	:= cx23885-cards.o cx23885-video.o cx23885-vbi.o 
cx23885-core.o cx23885-i2c.o cx23885-dvb.o cx23885-417.o
+cx23885-objs	:= cx23885-cards.o cx23885-video.o cx23885-vbi.o 
cx23885-core.o cx23885-i2c.o cx23885-dvb.o cx23885-417.o cx23885-alsa.o

  obj-$(CONFIG_VIDEO_CX23885) += cx23885.o

diff -uprN old/linux/drivers/media/video/cx25840/cx25840-core.c 
new/linux/drivers/media/video/cx25840/cx25840-core.c
--- old/linux/drivers/media/video/cx25840/cx25840-core.c	2008-08-09 
07:21:15.000000000 -0500
+++ new/linux/drivers/media/video/cx25840/cx25840-core.c	2008-08-26 
14:40:47.320185527 -0500
@@ -285,7 +285,9 @@ static void cx23885_initialize(struct i2

  	/* Trust the default xtal, no division */
  	/* This changes for the cx23888 products */
-	cx25840_write(client, 0x2, 0x76);
+	if (state->rev != 0x0000) /* FIXME: How to detect the bridge type ??? */
+		/* This causes image distortion on a true cx23885 board */
+		cx25840_write(client, 0x2, 0x76);

  	/* Bring down the regulator for AUX clk */
  	cx25840_write(client, 0x1, 0x40);

_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2008-09-08 23:23 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-29 21:01 [linux-dvb] [PATCH] cx23885 analog TV and audio support for HVR-1500 Tim Lucas
2008-08-29 21:56 ` Steven Toth
2008-08-30  0:41   ` Steven Toth
2008-08-30 18:11     ` Mijhail Moreyra
     [not found]     ` <e32e0e5d0808301411w1ae01563y65ce27d6c43e2beb@mail.gmail.com>
     [not found]       ` <e32e0e5d0808301456v4b5ca363l5a121b426438bd64@mail.gmail.com>
2008-08-31 22:04         ` Steven Toth
     [not found]           ` <e32e0e5d0809012006j72eb10e5r80ccf7e3211b8ee7@mail.gmail.com>
2008-09-02 16:08             ` Steven Toth
2008-09-03  2:28               ` Tim Lucas
2008-08-29 22:14 ` Michael Krufky
2008-08-29 23:02   ` Dustin Coates
2008-08-30  0:26     ` Michael Krufky
2008-08-30  0:30       ` Dustin Coates
2008-08-30  0:34   ` Steven Toth
2008-08-30  0:24 ` Mijhail Moreyra
  -- strict thread matches above, loose matches on Subject: below --
2008-09-05 14:31 Tim Lucas
2008-09-06 21:24 ` Tim Lucas
2008-09-08 23:22   ` Tim Lucas
2008-09-04 23:25 Tim Lucas
2008-09-05 13:22 ` Steven Toth
2008-08-26 20:33 Mijhail Moreyra
2008-08-26 20:53 ` Steven Toth
2008-08-26 21:03   ` Mijhail Moreyra
2008-08-26 22:01     ` Steven Toth
2008-08-26 23:18       ` Mijhail Moreyra
2008-08-27  6:59         ` Steven Toth
2008-08-29 19:52           ` Mijhail Moreyra
2008-08-29 19:55             ` Steven Toth
2008-08-29 20:17               ` Mijhail Moreyra
2008-08-29 20:19                 ` Steven Toth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox