From owner-freebsd-multimedia@FreeBSD.ORG Sun Nov 30 21:17:54 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1EF7B16A4CE for ; Sun, 30 Nov 2003 21:17:54 -0800 (PST) Received: from feith1.FEITH.COM (feith1.FEITH.COM [192.251.93.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1FB2F43FDD for ; Sun, 30 Nov 2003 21:17:51 -0800 (PST) (envelope-from john@feith.com) Received: from jwlab.FEITH.COM (jwlab.FEITH.COM [192.251.93.16]) by feith1.FEITH.COM (8.12.10+Sun/8.12.9) with ESMTP id hB15F1Jm008668 for ; Mon, 1 Dec 2003 00:15:01 -0500 (EST) Received: (from john@localhost) by jwlab.FEITH.COM (8.11.7+Sun/8.11.7) id hB15Erx26847 for multimedia@freebsd.org; Mon, 1 Dec 2003 00:14:53 -0500 (EST) Date: Mon, 1 Dec 2003 00:14:53 -0500 (EST) From: John Wehle Message-Id: <200312010514.hB15Erx26847@jwlab.FEITH.COM> To: multimedia@freebsd.org Content-Type: text X-Scanned-By: MIMEDefang 2.39 X-Archived: cashew.FEITH.COM Subject: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2003 05:17:54 -0000 I have written a FreeBSD 4.9 driver for the Hauppauge PVR-250 / 350 MPEG encoder cards which I'm happy to donate to the FreeBSD project if there's interest. It has only been tested with a PVR-250 version 1 card connected to NTSC cable TV, however support for the PVR-250 version 2 and PVR-350 has been coded as well as support for PAL and FM. The driver can supply VCD, SVCD, or DVD MPEG program streams (selectable using BT848_SCAPAREA). Issues / Limitations: 1) Only the MPEG encoder is supported. RAW data streams are not supported, nor is using the MPEG decoder present on the PVR-350. 2) The firmware has to be extracted from the Microsoft Windows driver and linked into the FreeBSD driver. I'm unsure who to contact at Hauppauge to get permission to include the firmware as part of the general FreeBSD driver distribution. 3) Encoding the VBI information into the MPEG data stream is not currently supported. I need more information from someone on what the MPEG encoder wants from the video decoder in order to support this. -- John ------------------------------------------------------------------------- | Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | | John Wehle | Fax: 1-215-540-5495 | | ------------------------------------------------------------------------- From owner-freebsd-multimedia@FreeBSD.ORG Mon Dec 1 02:15:23 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4BA0C16A4CE for ; Mon, 1 Dec 2003 02:15:23 -0800 (PST) Received: from mailout04.sul.t-online.com (mailout04.sul.t-online.com [194.25.134.18]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7152843FBF for ; Mon, 1 Dec 2003 02:15:20 -0800 (PST) (envelope-from Alexander@Leidinger.net) Received: from fwd09.aul.t-online.de by mailout04.sul.t-online.com with smtp id 1AQl2b-0003DO-00; Mon, 01 Dec 2003 11:12:29 +0100 Received: from Andro-Beta.Leidinger.net (rPrT40ZBQe61nJVGaOtayanKyVX5v88-3ZEk1acOzhI0vUImWhf4ZC@[217.83.30.233]) by fmrl09.sul.t-online.com with esmtp id 1AQl2O-1XYDey0; Mon, 1 Dec 2003 11:12:16 +0100 Received: from Magellan.Leidinger.net (Magellan.Leidinger.net [192.168.1.1]) hB1ACDeu005790 for ; Mon, 1 Dec 2003 11:12:14 +0100 (CET) (envelope-from Alexander@Leidinger.net) Received: from Magellan.Leidinger.net (netchild@localhost [127.0.0.1]) hB1ACBRW002437 for ; Mon, 1 Dec 2003 11:12:11 +0100 (CET) (envelope-from Alexander@Leidinger.net) Date: Mon, 1 Dec 2003 11:12:11 +0100 From: Alexander Leidinger To: multimedia@freebsd.org Message-Id: <20031201111211.6ab124a8.Alexander@Leidinger.net> X-Mailer: Sylpheed version 0.9.6claws (GTK+ 1.2.10; i386-portbld-freebsd5.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Seen: false X-ID: rPrT40ZBQe61nJVGaOtayanKyVX5v88-3ZEk1acOzhI0vUImWhf4ZC@t-dialin.net Subject: Using a USB scanner with SANE (via libusb on -current) X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2003 10:15:23 -0000 Hi, is someone able to use SANE with an USB scanner on a recent -current? I'm trying to add support for a CanoScan D660U to sane-backend 1.0.13, but the backend isn't able to read from the USB. This is with libusb 0.1.7_1. ---snip--- [sanei_usb] sanei_usb_find_devices: vendor=0x04a9, product=0x2207 [sanei_usb] sanei_usb_find_devices: vendor=0x04a9, product=0x2208 [sanei_usb] sanei_usb_open: trying to open device `libusb:/dev/usb0:/dev/ugen0' [sanei_usb] sanei_usb_open: found interupt-in endpoint (address 1) [sanei_usb] sanei_usb_open: found bulk-in endpoint (address 2) [sanei_usb] sanei_usb_open: found bulk-out endpoint (address 3) [sanei_usb] sanei_usb_open: opened usb device `libusb:/dev/usb0:/dev/ugen0' (*dn=0) [sanei_usb] sanei_usb_get_vendor_product: device 0: vendorID: 0x04a9, productID: 0x2208 [sanei_usb] sanei_usb_write_bulk: trying to write 4 bytes [sanei_usb] 0000: 01 69 00 01 .i.............. [sanei_usb] sanei_usb_write_bulk: wanted 4 bytes, wrote 4 bytes [sanei_usb] sanei_usb_read_bulk: trying to read 1 bytes USB error: error reading from bulk endpoint /dev/ugen0.2: Operation timed out [sanei_usb] sanei_usb_read_bulk: read failed: Operation timed out USB error: usb_clear_halt called, unimplemented on BSD [sanei_usb] sanei_usb_close: closing device 0 usb_os_close: closing endpoint 6 usb_os_close: closing endpoint 5 ---snip--- Bye, Alexander. -- Reboot America. http://www.Leidinger.net Alexander @ Leidinger.net GPG fingerprint = C518 BC70 E67F 143F BE91 3365 79E2 9C60 B006 3FE7 From owner-freebsd-multimedia@FreeBSD.ORG Mon Dec 1 12:34:34 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5236516A4CE for ; Mon, 1 Dec 2003 12:34:34 -0800 (PST) Received: from smtp5.wanadoo.nl (smtp5.wanadoo.nl [194.134.35.176]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A4DC4400D for ; Mon, 1 Dec 2003 12:34:27 -0800 (PST) (envelope-from steve@sohara.org) Received: from ams-gw.sohara.org (p0665.nas4-asd6.dial.wanadoo.nl [62.234.222.157]) by smtp5.wanadoo.nl (Postfix) with SMTP id 3F52D77E1E; Mon, 1 Dec 2003 21:34:24 +0100 (CET) Date: Mon, 1 Dec 2003 21:34:25 +0100 From: Steve O'Hara-Smith To: John Wehle Message-Id: <20031201213425.74b7d91e.steve@sohara.org> In-Reply-To: <200312010514.hB15Erx26847@jwlab.FEITH.COM> References: <200312010514.hB15Erx26847@jwlab.FEITH.COM> X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i386-portbld-freebsd4.9) X-Face: %]+HVL}K`P8>+8ZcY-WGHP6j@&mxMo9JH6_WdgIgUGH)JX/usO0%jy7T~IVgqjumD^OBqX,Kv^-GM6mlw(fI^$"QRKyZ$?xx/ Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2003 20:34:34 -0000 On Mon, 1 Dec 2003 00:14:53 -0500 (EST) John Wehle wrote: JW> I have written a FreeBSD 4.9 driver for the Hauppauge PVR-250 / 350 JW> MPEG encoder cards which I'm happy to donate to the FreeBSD project JW> if there's interest. I am very interested! -- C:>WIN | Directable Mirrors The computer obeys and wins. |A Better Way To Focus The Sun You lose and Bill collects. | licenses available - see: | http://www.sohara.org/ From owner-freebsd-multimedia@FreeBSD.ORG Mon Dec 1 16:14:04 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CEF2416A4CE for ; Mon, 1 Dec 2003 16:14:04 -0800 (PST) Received: from mail8.speakeasy.net (mail8.speakeasy.net [216.254.0.208]) by mx1.FreeBSD.org (Postfix) with ESMTP id 61FEB43FE5 for ; Mon, 1 Dec 2003 16:14:02 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 6567 invoked from network); 2 Dec 2003 00:14:01 -0000 Received: from unknown (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail8.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 2 Dec 2003 00:14:01 -0000 Received: from hydrogen.funkthat.com (tmzebi@localhost.funkthat.com [127.0.0.1])hB20DxgP028014; Mon, 1 Dec 2003 16:13:59 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id hB20DwpB028013; Mon, 1 Dec 2003 16:13:58 -0800 (PST) Date: Mon, 1 Dec 2003 16:13:58 -0800 From: John-Mark Gurney To: John Wehle Message-ID: <20031202001358.GB64793@funkthat.com> Mail-Followup-To: John Wehle , multimedia@freebsd.org References: <200312010514.hB15Erx26847@jwlab.FEITH.COM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200312010514.hB15Erx26847@jwlab.FEITH.COM> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2003 00:14:04 -0000 John Wehle wrote this message on Mon, Dec 01, 2003 at 00:14 -0500: > I have written a FreeBSD 4.9 driver for the Hauppauge PVR-250 / 350 > MPEG encoder cards which I'm happy to donate to the FreeBSD project cool, good to hear about other people are interested in video stuff on FreeBSD. I was working on a -current driver for the DC-10+ card, and decided to work on a general programming API for both programs and hardware drivers. (So that we stop cloning the terrible meteor interface and introducing strange bugs in basic handling). Do you have the specs for the card around? or pointers to them? Take a look at: http://people.FreeBSD.org/~jmg/videobsd.html for more info on what I've cooked up so far on the subject. Right now it's just words, but I want to make sure some things are good and complete before I start writing code to back it all. Thanks, ttyl. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-multimedia@FreeBSD.ORG Mon Dec 1 18:01:28 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A2E0116A4CF for ; Mon, 1 Dec 2003 18:01:28 -0800 (PST) Received: from crumpet.united-ware.com (ddsl-66-42-172-210.fuse.net [66.42.172.210]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8700F43FDF for ; Mon, 1 Dec 2003 18:01:25 -0800 (PST) (envelope-from mistry.7@osu.edu) Received: from 192.168.0.2 (adsl-64-108-96-51.dsl.wotnoh.ameritech.net [64.108.96.51]) (authenticated bits=0)hB2245Zh009939 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Mon, 1 Dec 2003 21:04:08 -0500 (EST) (envelope-from mistry.7@osu.edu) From: Anish Mistry To: John-Mark Gurney Date: Mon, 1 Dec 2003 20:59:13 -0500 User-Agent: KMail/1.5.3 References: <200312010514.hB15Erx26847@jwlab.FEITH.COM> <20031202001358.GB64793@funkthat.com> In-Reply-To: <20031202001358.GB64793@funkthat.com> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_5H/y/kztelNVb9g"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200312012059.21380.mistry.7@osu.edu> cc: freebsd-multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2003 02:01:28 -0000 --Boundary-02=_5H/y/kztelNVb9g Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Monday 01 December 2003 07:13 pm, John-Mark Gurney wrote: =2E.. > Take a look at: > http://people.FreeBSD.org/~jmg/videobsd.html > for more info on what I've cooked up so far on the subject. Right now > it's just words, but I want to make sure some things are good and > complete before I start writing code to back it all. >=20 I took a quick look through the page and just wanted to make a small=20 comment with my miniscule usb knowledge. About async'ing the library and=20 usb. It depends on the usb device driver. I know for a fact that ugen=20 does NOT buffer, which normally is pain, but in this case it may be good. = =20 We can always create a special u* device for video sources from usb if=20 needed that don't buffer, but aren't ugen ie. uvid*. Most other u*=20 devices buffer. If you need help coding, or other things, let me know I'd love to help. =2D-=20 Anish Mistry --Boundary-02=_5H/y/kztelNVb9g Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/y/H5xqA5ziudZT0RAnhvAKCCFEBkzfxQ7OdGOqA/2QmTMz1QnACfWpxk P4MbPMYmBFAlfiUy7eV2LgM= =h789 -----END PGP SIGNATURE----- --Boundary-02=_5H/y/kztelNVb9g-- From owner-freebsd-multimedia@FreeBSD.ORG Mon Dec 1 21:59:19 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AE53916A4CE for ; Mon, 1 Dec 2003 21:59:19 -0800 (PST) Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7985943F75 for ; Mon, 1 Dec 2003 21:59:17 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 21277 invoked from network); 2 Dec 2003 05:59:16 -0000 Received: from unknown (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail4.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 2 Dec 2003 05:59:16 -0000 Received: from hydrogen.funkthat.com (ripyjs@localhost.funkthat.com [127.0.0.1])hB25xFgP033152; Mon, 1 Dec 2003 21:59:15 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id hB25xFw9033151; Mon, 1 Dec 2003 21:59:15 -0800 (PST) Date: Mon, 1 Dec 2003 21:59:15 -0800 From: John-Mark Gurney To: Anish Mistry Message-ID: <20031202055915.GC64793@funkthat.com> Mail-Followup-To: Anish Mistry , freebsd-multimedia@freebsd.org References: <200312010514.hB15Erx26847@jwlab.FEITH.COM> <20031202001358.GB64793@funkthat.com> <200312012059.21380.mistry.7@osu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200312012059.21380.mistry.7@osu.edu> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: freebsd-multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2003 05:59:19 -0000 Anish Mistry wrote this message on Mon, Dec 01, 2003 at 20:59 -0500: Content-Description: signed data > On Monday 01 December 2003 07:13 pm, John-Mark Gurney wrote: > ... > > Take a look at: > > http://people.FreeBSD.org/~jmg/videobsd.html > > for more info on what I've cooked up so far on the subject. Right now > > it's just words, but I want to make sure some things are good and > > complete before I start writing code to back it all. > > > I took a quick look through the page and just wanted to make a small > comment with my miniscule usb knowledge. About async'ing the library and > usb. It depends on the usb device driver. I know for a fact that ugen > does NOT buffer, which normally is pain, but in this case it may be good. > We can always create a special u* device for video sources from usb if > needed that don't buffer, but aren't ugen ie. uvid*. Most other u* > devices buffer. Well, I was thinking/planning on doing the usb side as userland.. since we have the ugen driver in userland, and most of the work should be able to be done in userland, so it's less risk of running into kernel issues, (and supporting new devices w/o having to load a new module).. I was thinking of using asyncio to get around the blocking issue... I fixed one of the issues with the code recently, but plan to try to put it through it's paces soon... > If you need help coding, or other things, let me know I'd love to help. Cool.. :) I'll keep you in mind.. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-multimedia@FreeBSD.ORG Tue Dec 2 17:50:27 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 95FDB16A4CE for ; Tue, 2 Dec 2003 17:50:27 -0800 (PST) Received: from steelemr-loadb-nat-49.caltech.edu (SteeleMR-loadb-NAT-49.caltech.edu [131.215.49.69]) by mx1.FreeBSD.org (Postfix) with ESMTP id B35CA43FDF for ; Tue, 2 Dec 2003 17:50:26 -0800 (PST) (envelope-from kp@caltech.edu) Received: from water-dog (water-dog [192.168.1.26]) by water-ox-postvirus (Postfix) with ESMTP id 3FE9D26AC2F for ; Tue, 2 Dec 2003 17:50:25 -0800 (PST) Received: from water-ox ([192.168.1.10]) by water-dog (MailMonitor for SMTP v1.2.2 ) ; Tue, 2 Dec 2003 17:50:24 -0800 (PST) Received: from lithium.async.caltech.edu (lithium.async.caltech.edu [131.215.39.3]) by water-ox.its.caltech.edu (Postfix) with ESMTP id 8224B26AC14 for ; Tue, 2 Dec 2003 17:50:23 -0800 (PST) Date: Tue, 2 Dec 2003 17:50:23 -0800 (PST) From: Karl Papadantonakis X-Sender: kp@lithium.async.caltech.edu To: freebsd-multimedia@FreeBSD.ORG Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=0.0 tagged_above=-100000.0 required=5.0 X-Spam-Level: Subject: does FreeBSD 3.5.1 support soundcards? X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Dec 2003 01:50:27 -0000 Hi, I want really simple sampled-sound playback on my Dell Precision 340 running FreeBSD 3.5.1-RELEASE. It has builtin audio and three cheap soundcards (Crystal 4CH, AudioExcel AV511, and Diamond DT-688). No luck with pcm0 or snd0 with any of these cards. Any ideas? Thanks, Karl Papadantonakis email: kp@caltech.edu web: http://www.async.caltech.edu/~kp/ phone: (626) 395-4222 From owner-freebsd-multimedia@FreeBSD.ORG Tue Dec 2 21:25:10 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A0E4216A4CE for ; Tue, 2 Dec 2003 21:25:10 -0800 (PST) Received: from feith1.FEITH.COM (feith1.FEITH.COM [192.251.93.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9CCF943F3F for ; Tue, 2 Dec 2003 21:25:09 -0800 (PST) (envelope-from john@feith.com) Received: from jwlab.FEITH.COM (jwlab.FEITH.COM [192.251.93.16]) by feith1.FEITH.COM (8.12.10+Sun/8.12.9) with ESMTP id hB35OtOI028344; Wed, 3 Dec 2003 00:24:55 -0500 (EST) Received: (from john@localhost) by jwlab.FEITH.COM (8.11.7+Sun/8.11.7) id hB35OpJ28562; Wed, 3 Dec 2003 00:24:51 -0500 (EST) Date: Wed, 3 Dec 2003 00:24:51 -0500 (EST) From: John Wehle Message-Id: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> To: jmg@gate.funkthat.com Content-Type: text X-Scanned-By: MIMEDefang 2.39 X-Archived: cashew.FEITH.COM cc: multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Dec 2003 05:25:10 -0000 > Do you have the specs for the card around? or pointers to them? MPEG record specifications: MPEG1 recording at 1150K bits/sec (Video CD data rate) MPEG2 record datarates: 2MBit/sec, 4MBit/sec, 6Mbit/sec, 8Mbit/sec, 12Mbit/sec. Selections for DVD Standard play (8MBitsec), DVD Long Play (4MBit/sec) and DVD Extra Long Play (2MBit/sec) NTSC format at 29.97fps: Full D1: 720x480, MPEG1: 352x240 PAL format at 25fps: Full D1: 720x576, MPEG1: 352x288 Audio capture formats: 32/44.1/48 KHz, 16bit stereo, 192/224/384Kbits/sec More information is available at: http://www.hauppauge.com/html/wintvpvr250_datasheet.htm My unit has a Philips FI1236 MK2 tuner, SAA7115 rev 1 video decoder, MSP3435G-B6 audio decoder, and Conexant iTVC15 / CX23415 MPEG-2 Codec. > Take a look at: > http://people.FreeBSD.org/~jmg/videobsd.html You mention: Most capture cards have a seperate interface to capture sound. This isn't really the case for the PVR-250 / 350. The MPEG program stream from the card contains both sound and video. -- John ------------------------------------------------------------------------- | Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | | John Wehle | Fax: 1-215-540-5495 | | ------------------------------------------------------------------------- From owner-freebsd-multimedia@FreeBSD.ORG Wed Dec 3 09:57:07 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A66116A4CE for ; Wed, 3 Dec 2003 09:57:07 -0800 (PST) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id D394243FBD for ; Wed, 3 Dec 2003 09:57:03 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 14199 invoked from network); 3 Dec 2003 17:57:02 -0000 Received: from unknown (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 3 Dec 2003 17:57:02 -0000 Received: from hydrogen.funkthat.com (pipknw@localhost.funkthat.com [127.0.0.1])hB3Hv1gP066055; Wed, 3 Dec 2003 09:57:02 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id hB3Hv1Jl066054; Wed, 3 Dec 2003 09:57:01 -0800 (PST) Date: Wed, 3 Dec 2003 09:57:01 -0800 From: John-Mark Gurney To: John Wehle Message-ID: <20031203175701.GA54398@funkthat.com> Mail-Followup-To: John Wehle , multimedia@freebsd.org References: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Dec 2003 17:57:07 -0000 John Wehle wrote this message on Wed, Dec 03, 2003 at 00:24 -0500: > > Do you have the specs for the card around? or pointers to them? > > MPEG record specifications: > > MPEG1 recording at 1150K bits/sec (Video CD data rate) > MPEG2 record datarates: > 2MBit/sec, 4MBit/sec, 6Mbit/sec, 8Mbit/sec, 12Mbit/sec. > Selections for DVD Standard play (8MBitsec), DVD Long Play (4MBit/sec) > and DVD Extra Long Play (2MBit/sec) > NTSC format at 29.97fps: Full D1: 720x480, MPEG1: 352x240 > PAL format at 25fps: Full D1: 720x576, MPEG1: 352x288 > Audio capture formats: 32/44.1/48 KHz, 16bit stereo, 192/224/384Kbits/sec Nice, I saw this card in the store recently and was thinking it'd be nice to get this card running on FreeBSd. :) Might just have to go buy one.. Any work on integrating it with one of the many PVR programs out there? > > Take a look at: > > http://people.FreeBSD.org/~jmg/videobsd.html > > You mention: > > Most capture cards have a seperate interface to capture sound. > > This isn't really the case for the PVR-250 / 350. The MPEG program > stream from the card contains both sound and video. Yeh, And I did say most.. :) I was thinking that if the card does something special with sound, like integrate it into a codec stream, then the sound capture could/should? be set as a parameter of that device that does the integration... Because I assume that the card can only captuer sound as part of the mpeg codec stream? (going to check the specs). Do people think that sound should be brought under it's umbrela? I don't want to delay it too much by expanding the scope.. Just getting video is going to be difficult enough.. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-multimedia@FreeBSD.ORG Wed Dec 3 10:14:59 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF37E16A4CE for ; Wed, 3 Dec 2003 10:14:59 -0800 (PST) Received: from mailout07.sul.t-online.com (mailout07.sul.t-online.com [194.25.134.83]) by mx1.FreeBSD.org (Postfix) with ESMTP id 10D9E43FE1 for ; Wed, 3 Dec 2003 10:14:57 -0800 (PST) (envelope-from Alexander@Leidinger.net) Received: from fwd03.aul.t-online.de by mailout07.sul.t-online.com with smtp id 1ARbWZ-0005rF-07; Wed, 03 Dec 2003 19:14:55 +0100 Received: from Andro-Beta.Leidinger.net (Tb2XCZZBweVRn-fPAmbU-QUwn3kn816z2VtfX6e5C08X9o6iON9FYi@[217.229.220.33]) by fmrl03.sul.t-online.com with esmtp id 1ARbWO-1oksN60; Wed, 3 Dec 2003 19:14:44 +0100 Received: from Magellan.Leidinger.net (Magellan.Leidinger.net [192.168.1.1]) hB3IEibk071710 for ; Wed, 3 Dec 2003 19:14:45 +0100 (CET) (envelope-from Alexander@Leidinger.net) Received: from Magellan.Leidinger.net (netchild@localhost [127.0.0.1]) hB3IEirV073304 for ; Wed, 3 Dec 2003 19:14:44 +0100 (CET) (envelope-from Alexander@Leidinger.net) Date: Wed, 3 Dec 2003 19:14:44 +0100 From: Alexander Leidinger To: freebsd-multimedia@freebsd.org Message-Id: <20031203191444.7fc637c7.Alexander@Leidinger.net> In-Reply-To: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> References: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> X-Mailer: Sylpheed version 0.9.6claws (GTK+ 1.2.10; i386-portbld-freebsd5.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Seen: false X-ID: Tb2XCZZBweVRn-fPAmbU-QUwn3kn816z2VtfX6e5C08X9o6iON9FYi@t-dialin.net Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Dec 2003 18:14:59 -0000 On Wed, 3 Dec 2003 00:24:51 -0500 (EST) John Wehle wrote: > More information is available at: > > http://www.hauppauge.com/html/wintvpvr250_datasheet.htm > > My unit has a Philips FI1236 MK2 tuner, SAA7115 rev 1 video decoder, > MSP3435G-B6 audio decoder, and Conexant iTVC15 / CX23415 MPEG-2 Codec. And for some information about the codec http://ivtv.sourceforge.net/ (Linux driver effort). Bye, Alexander. -- No funny .sig because of a bug somewhere... http://www.Leidinger.net Alexander @ Leidinger.net GPG fingerprint = C518 BC70 E67F 143F BE91 3365 79E2 9C60 B006 3FE7 From owner-freebsd-multimedia@FreeBSD.ORG Wed Dec 3 14:07:30 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E881616A4CF for ; Wed, 3 Dec 2003 14:07:30 -0800 (PST) Received: from crumpet.united-ware.com (ddsl-66-42-172-210.fuse.net [66.42.172.210]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8575E43F93 for ; Wed, 3 Dec 2003 14:07:29 -0800 (PST) (envelope-from mistry.7@osu.edu) Received: from 192.168.0.2 (adsl-64-108-96-51.dsl.wotnoh.ameritech.net [64.108.96.51]) (authenticated bits=0)hB3MALZh032085 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Wed, 3 Dec 2003 17:10:23 -0500 (EST) (envelope-from mistry.7@osu.edu) From: Anish Mistry To: John-Mark Gurney Date: Wed, 3 Dec 2003 17:05:35 -0500 User-Agent: KMail/1.5.3 References: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> <20031203175701.GA54398@funkthat.com> In-Reply-To: <20031203175701.GA54398@funkthat.com> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_34lz/ZbIHueibE4"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200312031705.43991.mistry.7@osu.edu> cc: freebsd-multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Dec 2003 22:07:31 -0000 --Boundary-02=_34lz/ZbIHueibE4 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Wednesday 03 December 2003 12:57 pm, John-Mark Gurney wrote: >=20 > Do people think that sound should be brought under it's umbrela? > I don't want to delay it too much by expanding the scope.. Just getting > video is going to be difficult enough.. >=20 I don't think so, but the api should still allow for it. Maybe there=20 should be 2 capture modes. 1) Raw video ie. most tv cards just video=20 frame. 2) encoded video and sound just passes the data through to be=20 written to a file or such. =2D-=20 Anish Mistry --Boundary-02=_34lz/ZbIHueibE4 Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/zl43xqA5ziudZT0RAtjNAJ9mfE+WKDSKCAHFR5PT4XzE+bgkrQCcDZ3M l44cuyUEX8zkb2ciDRHC0AQ= =5xfp -----END PGP SIGNATURE----- --Boundary-02=_34lz/ZbIHueibE4-- From owner-freebsd-multimedia@FreeBSD.ORG Wed Dec 3 16:37:14 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0115216A4CE for ; Wed, 3 Dec 2003 16:37:14 -0800 (PST) Received: from arg1.demon.co.uk (arg1.demon.co.uk [62.49.12.213]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B18D43FE3 for ; Wed, 3 Dec 2003 16:37:12 -0800 (PST) (envelope-from arg-bsd@arg.me.uk) Received: by arg1.demon.co.uk (Postfix, from userid 1002) id 363839B32; Thu, 4 Dec 2003 00:37:11 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by arg1.demon.co.uk (Postfix) with ESMTP id 277C65D6A; Thu, 4 Dec 2003 00:37:11 +0000 (GMT) Date: Thu, 4 Dec 2003 00:37:10 +0000 (GMT) From: Andrew Gordon X-X-Sender: freebsd@server.arg.sj.co.uk To: John-Mark Gurney In-Reply-To: <20031203175701.GA54398@funkthat.com> Message-ID: <20031204002502.X49643@server.arg.sj.co.uk> References: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> <20031203175701.GA54398@funkthat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2003 00:37:14 -0000 On Wed, 3 Dec 2003, John-Mark Gurney wrote: > > > > > This isn't really the case for the PVR-250 / 350. The MPEG program > > stream from the card contains both sound and video. > > Yeh, And I did say most.. :) I was thinking that if the card does > something special with sound, like integrate it into a codec stream, > then the sound capture could/should? be set as a parameter of that > device that does the integration... Because I assume that the card > can only captuer sound as part of the mpeg codec stream? (going to > check the specs). > > Do people think that sound should be brought under it's umbrela? > I don't want to delay it too much by expanding the scope.. Just getting > video is going to be difficult enough.. Well, some means of supporting sound alongside video is certainly required: if the API doesn't handle sound explicitly, then it needs to convey the necessary timing information so that the sound can be handled via separate APIs without losing synchronisation. For many kinds of device, all you need is to report the delay through the device (and it's associated driver buffering). However, some kinds of device don't have constant delay and timestamps are required. Devices such as the MPEG capture card mentioned earlier are a problem to fit into such a scheme, as although the video will come out nicely timestamped (and the audio likewise), there may not be a means to relate those timestamps to real-time (ie. you can achieve A/V-sync between A and V streams captured on the card as designed, but it's hard to synchronize with sound captured on a standard sound-card at the same time, for example). From owner-freebsd-multimedia@FreeBSD.ORG Thu Dec 4 12:17:52 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AA07D16A4CE for ; Thu, 4 Dec 2003 12:17:52 -0800 (PST) Received: from meitner.wh.uni-dortmund.de (meitner.wh.uni-dortmund.de [129.217.129.133]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B41943FBD for ; Thu, 4 Dec 2003 12:17:51 -0800 (PST) (envelope-from michaelnottebrock@gmx.net) Received: from lofi.dyndns.org (pc2-105.intern.meitner [10.3.12.105]) by meitner.wh.uni-dortmund.de (Postfix) with ESMTP id 8CDC9167589; Thu, 4 Dec 2003 21:17:49 +0100 (CET) Received: from kiste.my.domain (kiste.my.domain [192.168.8.4]) (authenticated bits=0) by lofi.dyndns.org (8.12.9p1/8.12.9) with ESMTP id hB4KHiRO010536 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Thu, 4 Dec 2003 21:17:46 +0100 (CET) (envelope-from michaelnottebrock@gmx.net) From: Michael Nottebrock Organization: FreeBSD To: Thomas , freebsd-multimedia@FreeBSD.org Date: Thu, 4 Dec 2003 21:17:37 +0100 User-Agent: KMail/1.5.4 References: <3FC95E70.3000200@sbcglobal.net> In-Reply-To: <3FC95E70.3000200@sbcglobal.net> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_nZ5z/YDPz7xwItG"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200312042117.44026.michaelnottebrock@gmx.net> X-Virus-Scanned: by amavisd-new Subject: Re: A pcm driver for Event/Echo Layla sound interface X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2003 20:17:52 -0000 --Boundary-02=_nZ5z/YDPz7xwItG Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Sunday 30 November 2003 04:05, Thomas wrote: > I am still ironing out some issues and the driver is a long way from > running on the other Echo devices. But, I wanted to just see if this is > interesting to anybody else. I can, of course, make all the source code > available. Please do. Any working driver for new hardware is much needed. =2D-=20 ,_, | Michael Nottebrock | lofi@freebsd.org (/^ ^\) | FreeBSD - The Power to Serve | http://www.freebsd.org \u/ | K Desktop Environment on FreeBSD | http://freebsd.kde.org --Boundary-02=_nZ5z/YDPz7xwItG Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/z5ZnXhc68WspdLARAuPTAJ0QvbEazCTraTHkZyefJY+HKSASowCgjcqa A9XziFDE8dnmsQY4eJmqX5U= =YPtK -----END PGP SIGNATURE----- --Boundary-02=_nZ5z/YDPz7xwItG-- From owner-freebsd-multimedia@FreeBSD.ORG Thu Dec 4 13:18:25 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D712416A4CE for ; Thu, 4 Dec 2003 13:18:25 -0800 (PST) Received: from mail1.speakeasy.net (mail1.speakeasy.net [216.254.0.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2F2D843FDF for ; Thu, 4 Dec 2003 13:18:24 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 16445 invoked from network); 4 Dec 2003 21:18:23 -0000 Received: from unknown (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail1.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 4 Dec 2003 21:18:23 -0000 Received: from hydrogen.funkthat.com (efezkl@localhost.funkthat.com [127.0.0.1])hB4LIMgP090459; Thu, 4 Dec 2003 13:18:23 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id hB4LIMhB090458; Thu, 4 Dec 2003 13:18:22 -0800 (PST) Date: Thu, 4 Dec 2003 13:18:22 -0800 From: John-Mark Gurney To: Andrew Gordon Message-ID: <20031204211821.GJ54398@funkthat.com> Mail-Followup-To: Andrew Gordon , multimedia@freebsd.org References: <200312030524.hB35OpJ28562@jwlab.FEITH.COM> <20031203175701.GA54398@funkthat.com> <20031204002502.X49643@server.arg.sj.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031204002502.X49643@server.arg.sj.co.uk> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2003 21:18:26 -0000 Andrew Gordon wrote this message on Thu, Dec 04, 2003 at 00:37 +0000: > > > This isn't really the case for the PVR-250 / 350. The MPEG program > > > stream from the card contains both sound and video. > > > > Yeh, And I did say most.. :) I was thinking that if the card does > > something special with sound, like integrate it into a codec stream, > > then the sound capture could/should? be set as a parameter of that > > device that does the integration... Because I assume that the card > > can only captuer sound as part of the mpeg codec stream? (going to > > check the specs). > > > > Do people think that sound should be brought under it's umbrela? > > I don't want to delay it too much by expanding the scope.. Just getting > > video is going to be difficult enough.. > > Well, some means of supporting sound alongside video is certainly > required: if the API doesn't handle sound explicitly, then it needs to > convey the necessary timing information so that the sound can be handled > via separate APIs without losing synchronisation. Well, if the sound is completely encoded in the codec stream, then videobus would not know about it... I do plan on doing kernel side timestamp tagging of frames so that the upper layers will be able to get this info. The only problem with this is that the timestamps may not agree with the sound card unless the soundcard/code also does time stamping since the local clock could run (and often do) at different rates than the sound sampling code... > For many kinds of device, all you need is to report the delay through the > device (and it's associated driver buffering). However, some kinds of > device don't have constant delay and timestamps are required. Devices > such as the MPEG capture card mentioned earlier are a problem to fit into > such a scheme, as although the video will come out nicely timestamped (and > the audio likewise), there may not be a means to relate those timestamps > to real-time (ie. you can achieve A/V-sync between A and V streams > captured on the card as designed, but it's hard to synchronize with sound > captured on a standard sound-card at the same time, for example). Yeh, It's a sticky problem that I don't want to completely ignore it, but from my point of view, about the only thing I can do is to timestamp against the local clock, anymore requires significant fingers in each subsystem's pie to be doable... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-multimedia@FreeBSD.ORG Thu Dec 4 22:19:14 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 93E7E16A4CE for ; Thu, 4 Dec 2003 22:19:14 -0800 (PST) Received: from feith1.FEITH.COM (feith1.FEITH.COM [192.251.93.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 032C243FE1 for ; Thu, 4 Dec 2003 22:18:43 -0800 (PST) (envelope-from john@feith.com) Received: from jwlab.FEITH.COM (jwlab.FEITH.COM [192.251.93.16]) by feith1.FEITH.COM (8.12.10+Sun/8.12.9) with ESMTP id hB56IcOI019118; Fri, 5 Dec 2003 01:18:38 -0500 (EST) Received: (from john@localhost) by jwlab.FEITH.COM (8.11.7+Sun/8.11.7) id hB56IYi00447; Fri, 5 Dec 2003 01:18:34 -0500 (EST) Date: Fri, 5 Dec 2003 01:18:34 -0500 (EST) From: John Wehle Message-Id: <200312050618.hB56IYi00447@jwlab.FEITH.COM> To: multimedia@freebsd.org Content-Type: text X-Scanned-By: MIMEDefang 2.39 X-Archived: cashew.FEITH.COM cc: jmg@gate.funkthat.com Subject: FreeBSD 4.9 Hauppauge PVR-250 / 350 Driver Patch X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2003 06:19:14 -0000 To use the Hauppauge PVR-250 / 350 on FreeBSD 4.9: 1) Apply the enclosed patch. 2) Place a current version of hcwpvrp2.sys from the Hauppauge drivers into /sys/dev/cxm. Extract the the firmware by: # cd /sys/dev/cxm # cc -o cxm_extract_firmware cxm_extract_firmware.c # ./cxm_extract_firmware hcwpvrp2.sys 3) Rebuilt your kernel with: device iicbus device iicbb as part of the configuration. 4) Install the new kernel and reboot. 5) Make and install the cxm driver by: # cd /sys/modules/cxm # make # cp cxm/cxm.ko cxm_iic/cxm_iic.ko /modules # kldload cxm_iic # kldload cxm At which point your console should say something like: cxm0: mem 0xd8000000-0xdbffffff irq 12 at device 10 .0 on pci0 cxm_iic0: on cxm0 iicbb0: on cxm_iic0 cxm0: Philips FI1236 MK2 tuner cxm0: SAA7115 rev 1 video decoder cxm0: MSP3435G-B6 audio decoder cxm0: IR Remote cxm0: encoder firmware version 0x2040011 cxm0: decoder firmware version 0x2020023 6) Make the device nodes by: # cd /dev # ./MAKEDEV bktr0 A subset of the bt848 and meteor ioctls are supported. The more interesting ones being: TVTUNER_SETCHNL - Set the channel (default to 4). BT848_SCAPAREA - Set the capture area / format (defaults to DVD). VCD: 352 x 240 or 352 x 288 SVCD: 480 x 480 or 480 x 576 DVD: 720 x 480 or 720 x 576 METEORCAPTUR - Start / stop the capture. Capture is also started if a read occurs when the data buffer is empty. To capture a MPEG program stream from the current channel simply cat /dev/bktr0 > filename.mpeg. Though to ensure a clean capture you probably want to do something like: 1) Read data until the TV show has ended. 2) Use METEORCAPTUR to end the capture. 3) Use poll to determine if there is any data remaining in the device. Read the data as long as poll says there's data in the buffer. otherwise the end of the mpeg program stream will probably be corrupt. Enjoy, John Wehle ------------------8<------------------------8<------------------------ *** dev/iicbus/iicbb.c.ORIGINAL Sat Apr 20 12:38:43 2002 --- dev/iicbus/iicbb.c Wed Sep 24 02:05:59 2003 *************** static int iicbb_read(device_t dev, char *** 345,349 **** --- 345,350 ---- } DRIVER_MODULE(iicbb, bti2c, iicbb_driver, iicbb_devclass, 0, 0); + DRIVER_MODULE(iicbb, cxm_iic, iicbb_driver, iicbb_devclass, 0, 0); DRIVER_MODULE(iicbb, lpbb, iicbb_driver, iicbb_devclass, 0, 0); DRIVER_MODULE(iicbb, viapm, iicbb_driver, iicbb_devclass, 0, 0); *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm.c Thu Dec 4 00:05:50 2003 *************** *** 0 **** --- 1,2293 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Conexant MPEG-2 Codec driver. Supports the CX23415 / CX23416 + * chips that are on the Hauppauge PVR-250 and PVR-350 video + * capture cards. Currently only the encoder is supported. + * + * This driver was written using the invaluable information + * compiled by The IvyTV Project (ivtv.sourceforge.net). + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + + #include + #include + + #include + #include + + #include + + + /* + * Various supported device vendors/types and their names. + */ + static struct cxm_dev cxm_devs[] = { + { CXM_VENDORID_CONEXANT, CXM_DEVICEID_CONEXANT_iTVC15, + "Conexant iTVC15 MPEG Coder" }, + { CXM_VENDORID_CONEXANT, CXM_DEVICEID_CONEXANT_iTVC16, + "Conexant iTVC16 MPEG Coder" }, + { 0, 0, NULL } + }; + + + static int cxm_probe( device_t dev ); + static int cxm_attach( device_t dev ); + static int cxm_detach( device_t dev ); + static int cxm_shutdown( device_t dev ); + static void cxm_intr( void *arg ); + + static int cxm_read_ivar( device_t bus, device_t dev, + int index, uintptr_t* val); + static int cxm_write_ivar( device_t bus, device_t dev, + int index, uintptr_t val); + + + static device_method_t cxm_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, cxm_probe), + DEVMETHOD(device_attach, cxm_attach), + DEVMETHOD(device_detach, cxm_detach), + DEVMETHOD(device_shutdown, cxm_shutdown), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_read_ivar, cxm_read_ivar), + DEVMETHOD(bus_write_ivar, cxm_write_ivar), + + { 0, 0 } + }; + + static driver_t cxm_driver = { + "cxm", + cxm_methods, + sizeof(struct cxm_softc), + }; + + static devclass_t cxm_devclass; + + static d_open_t cxm_open; + static d_close_t cxm_close; + static d_read_t cxm_read; + static d_ioctl_t cxm_ioctl; + static d_poll_t cxm_poll; + + #define CDEV_MAJOR 92 + static struct cdevsw cxm_cdevsw = { + /* open */ cxm_open, + /* close */ cxm_close, + /* read */ cxm_read, + /* write */ nowrite, + /* ioctl */ cxm_ioctl, + /* poll */ cxm_poll, + /* mmap */ nommap, + /* strategy */ nostrategy, + /* name */ "cxm", + /* maj */ CDEV_MAJOR, + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ 0, + /* bmaj */ -1 + }; + + MODULE_DEPEND(cxm, cxm_iic, 1, 1, 1); + DRIVER_MODULE(cxm, pci, cxm_driver, cxm_devclass, 0, 0); + + + /* + * Various profiles. + */ + static struct cxm_codec_profile vcd_ntsc_profile = { + "MPEG-1 VideoCD NTSC video and MPEG audio", + CXM_FW_STREAM_TYPE_VCD, + 30, + 352, 240, 480, + 12, + 0, + { 1, 1150000, 0 }, + { 0, 15, 3}, + /* + * Spatial filter = Auto, Temporal filter = Auto + * Median filter = Horizontal / Vertical + * Spatial filter value = 0, Temporal filter value = 0 + */ + { 3, 3, 0, 0 }, + /* 44.1 Khz, MPEG-1 Layer II, 224 kb/s */ + 0xb8 + }; + + static struct cxm_codec_profile vcd_pal_profile = { + "MPEG-1 VideoCD PAL video and MPEG audio", + CXM_FW_STREAM_TYPE_VCD, + 25, + 352, 288, 576, + 8, + 0, + { 1, 1150000, 0 }, + { 0, 12, 3}, + /* + * Spatial filter = Auto, Temporal filter = Auto + * Median filter = Horizontal / Vertical + * Spatial filter value = 0, Temporal filter value = 0 + */ + { 3, 3, 0, 0 }, + /* 44.1 Khz, MPEG-1 Layer II, 224 kb/s */ + 0xb8 + }; + + static struct cxm_codec_profile svcd_ntsc_profile = { + "MPEG-2 SuperVCD NTSC video and MPEG audio", + CXM_FW_STREAM_TYPE_MPEG2_PROGRAM, + 30, + 480, 480, 480, + 2, + 0, + /* 2.5 Mb/s peak limit to keep bbdmux followed by mplex -f 4 happy */ + { 0, 1150000, 2500000 }, + { 0, 15, 3}, + /* + * Spatial filter = Auto, Temporal filter = Auto + * Median filter = Horizontal / Vertical + * Spatial filter value = 0, Temporal filter value = 0 + */ + { 3, 3, 0, 0 }, + /* 44.1 Khz, MPEG-1 Layer II, 224 kb/s */ + 0xb8 + }; + + static struct cxm_codec_profile svcd_pal_profile = { + "MPEG-2 SuperVCD PAL video and MPEG audio", + CXM_FW_STREAM_TYPE_MPEG2_PROGRAM, + 25, + 480, 576, 576, + 2, + 0, + /* 2.5 Mb/s peak limit to keep bbdmux followed by mplex -f 4 happy */ + { 0, 1150000, 2500000 }, + { 0, 12, 3}, + /* + * Spatial filter = Auto, Temporal filter = Auto + * Median filter = Horizontal / Vertical + * Spatial filter value = 0, Temporal filter value = 0 + */ + { 3, 3, 0, 0 }, + /* 44.1 Khz, MPEG-1 Layer II, 224 kb/s */ + 0xb8 + }; + + static struct cxm_codec_profile dvd_ntsc_profile = { + "MPEG-2 DVD NTSC video and MPEG audio", + CXM_FW_STREAM_TYPE_DVD, + 30, + 720, 480, 480, + 2, + 0, + /* 9.52 Mb/s peak limit to keep bbdmux followed by mplex -f 8 happy */ + { 0, 9000000, 9520000 }, + { 0, 15, 3}, + /* + * Spatial filter = Auto, Temporal filter = Auto + * Median filter = Horizontal / Vertical + * Spatial filter value = 0, Temporal filter value = 0 + */ + { 3, 3, 0, 0 }, + /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ + 0xe9 + }; + + static struct cxm_codec_profile dvd_pal_profile = { + "MPEG-2 DVD PAL video and MPEG audio", + CXM_FW_STREAM_TYPE_DVD, + 25, + 720, 576, 576, + 2, + 0, + /* 9.52 Mb/s peak limit to keep bbdmux followed by mplex -f 8 happy */ + { 0, 9000000, 9520000 }, + { 0, 12, 3}, + /* + * Spatial filter = Auto, Temporal filter = Auto + * Median filter = Horizontal / Vertical + * Spatial filter value = 0, Temporal filter value = 0 + */ + { 3, 3, 0, 0 }, + /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ + 0xe9 + }; + + static const struct cxm_codec_profile + *codec_profiles[] = { + &vcd_ntsc_profile, + &vcd_pal_profile, + &svcd_ntsc_profile, + &svcd_pal_profile, + &dvd_ntsc_profile, + &dvd_pal_profile + }; + + + static unsigned int + cxm_queue_firmware_command( struct cxm_softc *sc, + enum cxm_mailbox_name mbx_name, u_int32_t cmd, + u_int32_t *parameters, unsigned int nparameters ) + { + unsigned int i; + unsigned int mailbox; + u_int32_t completed_command; + u_int32_t flags; + intrmask_t s; + + if (nparameters > CXM_MBX_MAX_PARAMETERS) { + printf("%s: too many parameters for mailbox\n", sc->name); + return -1; + } + + mailbox = 0; + + switch (mbx_name) { + case cxm_dec_mailbox: + mailbox = sc->dec_mbx + + CXM_MBX_FW_CMD_MAILBOX *sizeof(struct cxm_mailbox); + break; + + case cxm_enc_mailbox: + mailbox = sc->enc_mbx + + CXM_MBX_FW_CMD_MAILBOX *sizeof(struct cxm_mailbox); + break; + + default: + return -1; + } + + s = spltty(); + for (i = 0; i < CXM_MBX_FW_CMD_MAILBOXES; i++) { + flags = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, flags)); + if (! (flags & CXM_MBX_FLAG_IN_USE) ) + break; + + /* + * Mail boxes containing certain completed commands + * for which the results are never needed can be reused. + */ + + if ((flags & (CXM_MBX_FLAG_DRV_DONE | CXM_MBX_FLAG_FW_DONE)) + == (CXM_MBX_FLAG_DRV_DONE | CXM_MBX_FLAG_FW_DONE)) { + completed_command + = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, command)); + + /* + * DMA results are always check by reading the + * DMA status register ... never by checking + * the mailbox after the command has completed. + */ + + if (completed_command == CXM_FW_CMD_SCHED_DMA_TO_HOST) + break; + } + + mailbox += sizeof(struct cxm_mailbox); + } + + if (i >= CXM_MBX_FW_CMD_MAILBOXES) { + splx(s); + return -1; + } + + CSR_WRITE_4(sc, mailbox + offsetof(struct cxm_mailbox, flags), + CXM_MBX_FLAG_IN_USE); + splx(s); + + CSR_WRITE_4(sc, mailbox + offsetof(struct cxm_mailbox, command), cmd); + CSR_WRITE_4(sc, mailbox + offsetof(struct cxm_mailbox, timeout), + CXM_FW_STD_TIMEOUT); + + for (i = 0; i < nparameters; i++) + CSR_WRITE_4(sc, + mailbox + + offsetof(struct cxm_mailbox, parameters) + + i * sizeof(u_int32_t), + *(parameters + i)); + + for ( ; i < CXM_MBX_MAX_PARAMETERS; i++) + CSR_WRITE_4(sc, + mailbox + + offsetof(struct cxm_mailbox, parameters) + + i * sizeof(u_int32_t), 0); + + CSR_WRITE_4(sc, mailbox + offsetof(struct cxm_mailbox, flags), + CXM_MBX_FLAG_IN_USE | CXM_MBX_FLAG_DRV_DONE); + + return mailbox; + } + + + static int + cxm_firmware_command( struct cxm_softc *sc, + enum cxm_mailbox_name mbx_name, u_int32_t cmd, + u_int32_t *parameters, unsigned int nparameters ) + { + const char *wmesg; + unsigned int *bmp; + unsigned int i; + unsigned int mailbox; + u_int32_t flags; + u_int32_t result; + + bmp = NULL; + wmesg = ""; + + switch (mbx_name) { + case cxm_dec_mailbox: + bmp = &sc->dec_mbx; + wmesg = "cxmdfw"; + break; + + case cxm_enc_mailbox: + bmp = &sc->enc_mbx; + wmesg = "cxmefw"; + break; + + default: + return -1; + } + + mailbox = cxm_queue_firmware_command(sc, mbx_name, cmd, + parameters, nparameters); + if (mailbox == -1) { + printf("%s: no free mailboxes\n", sc->name); + return -1; + } + + /* Give the firmware a chance to start processing the request */ + (void)tsleep(bmp, PWAIT, wmesg, hz / 100); + + for (i = 0; i < 100; i++) { + flags = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, flags)); + if ( (flags & CXM_MBX_FLAG_FW_DONE) ) + break; + + /* Wait for 10ms */ + (void)tsleep(bmp, PWAIT, wmesg, hz / 100); + } + + if (i >= 100) { + printf("%s: timeout\n", sc->name); + return -1; + } + + result = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, result)); + + for (i = 0; i < nparameters; i++) + *(parameters + i) + = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, parameters) + + i * sizeof(u_int32_t)); + + CSR_WRITE_4(sc, mailbox + offsetof(struct cxm_mailbox, flags), 0); + + return result == 0 ? 0 : -1; + } + + + static int + cxm_firmware_command_nosleep( struct cxm_softc *sc, + enum cxm_mailbox_name mbx_name, u_int32_t cmd, + u_int32_t *parameters, unsigned int nparameters ) + { + unsigned int i; + unsigned int mailbox; + u_int32_t flags; + u_int32_t result; + + for (i = 0; i < 100; i++) { + mailbox = cxm_queue_firmware_command(sc, mbx_name, cmd, + parameters, nparameters); + if (mailbox != -1) + break; + + /* Wait for 10ms */ + DELAY(10000); + } + + if (i >= 100) { + printf("%s: no free mailboxes\n", sc->name); + return -1; + } + + /* Give the firmware a chance to start processing the request */ + DELAY(10000); + + for (i = 0; i < 100; i++) { + flags = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, flags)); + if ( (flags & CXM_MBX_FLAG_FW_DONE) ) + break; + + /* Wait for 10ms */ + DELAY(10000); + } + + if (i >= 100) { + printf("%s: timeout\n", sc->name); + return -1; + } + + result = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, result)); + + for (i = 0; i < nparameters; i++) + *(parameters + i) + = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, parameters) + + i * sizeof(u_int32_t)); + + CSR_WRITE_4(sc, mailbox + offsetof(struct cxm_mailbox, flags), 0); + + return result == 0 ? 0 : -1; + } + + + static int + cxm_stop_firmware( struct cxm_softc *sc ) + { + + if (cxm_firmware_command_nosleep(sc, cxm_enc_mailbox, + CXM_FW_CMD_ENC_HALT_FW, NULL, 0) < 0) + return -1; + + if (sc->type == cxm_iTVC15_type + && cxm_firmware_command_nosleep(sc, cxm_dec_mailbox, + CXM_FW_CMD_DEC_HALT_FW, + NULL, 0) < 0) + return -1; + + /* Wait for 10ms */ + DELAY(10000); + + return 0; + } + + + static int + cxm_stop_hardware( struct cxm_softc *sc ) + { + + if (sc->cxm_iic) { + if (cxm_saa7115_mute(sc) < 0) + return -1; + if (cxm_msp_mute(sc) < 0) + return -1; + } + + /* Halt the firmware */ + if (sc->enc_mbx != -1) { + if (cxm_stop_firmware(sc) < 0) + return -1; + } + + /* Mask all interrupts */ + sc->irq_mask = 0xffffffff; + CSR_WRITE_4(sc, CXM_REG_IRQ_MASK, sc->irq_mask); + + /* Stop VDM */ + CSR_WRITE_4(sc, CXM_REG_VDM, CXM_CMD_VDM_STOP); + + /* Stop AO */ + CSR_WRITE_4(sc, CXM_REG_AO, CXM_CMD_AO_STOP); + + /* Ping (?) APU */ + CSR_WRITE_4(sc, CXM_REG_APU, CXM_CMD_APU_PING); + + /* Stop VPU */ + CSR_WRITE_4(sc, CXM_REG_VPU, sc->type == cxm_iTVC15_type + ? CXM_CMD_VPU_STOP15 + : CXM_CMD_VPU_STOP16); + + /* Reset Hw Blocks */ + CSR_WRITE_4(sc, CXM_REG_HW_BLOCKS, CXM_CMD_HW_BLOCKS_RST); + + /* Stop SPU */ + CSR_WRITE_4(sc, CXM_REG_SPU, CXM_CMD_SPU_STOP); + + /* Wait for 10ms */ + DELAY(10000); + + return 0; + } + + + static int + cxm_download_firmware( struct cxm_softc *sc ) + { + unsigned int i; + const u_int32_t *fw; + + /* Download the encoder firmware */ + fw = (const u_int32_t *)cxm_enc_fw; + for (i = 0; i < CXM_FW_SIZE; i += sizeof(*fw)) + CSR_WRITE_4(sc, CXM_MEM_ENC + i, *fw++); + + /* Download the decoder firmware */ + if (sc->type == cxm_iTVC15_type) { + fw = (const u_int32_t *)cxm_dec_fw; + for (i = 0; i < CXM_FW_SIZE; i += sizeof(*fw)) + CSR_WRITE_4(sc, CXM_MEM_DEC + i, *fw++); + } + + return 0; + } + + + static int + cxm_init_hardware( struct cxm_softc *sc ) + { + unsigned int i; + unsigned int mailbox; + u_int32_t parameter; + + if (cxm_stop_hardware(sc) < 0) + return -1; + + /* Initialize encoder SDRAM pre-charge */ + CSR_WRITE_4(sc, CXM_REG_ENC_SDRAM_PRECHARGE, + CXM_CMD_SDRAM_PRECHARGE_INIT); + + /* Initialize encoder SDRAM refresh to 1us */ + CSR_WRITE_4(sc, CXM_REG_ENC_SDRAM_REFRESH, + CXM_CMD_SDRAM_REFRESH_INIT); + + /* Initialize decoder SDRAM pre-charge */ + CSR_WRITE_4(sc, CXM_REG_DEC_SDRAM_PRECHARGE, + CXM_CMD_SDRAM_PRECHARGE_INIT); + + /* Initialize decoder SDRAM refresh to 1us */ + CSR_WRITE_4(sc, CXM_REG_DEC_SDRAM_REFRESH, + CXM_CMD_SDRAM_REFRESH_INIT); + + /* Wait for 600ms */ + DELAY(600000); + + if (cxm_download_firmware(sc) < 0) + return -1; + + /* Enable SPU */ + CSR_WRITE_4(sc, CXM_REG_SPU, + CSR_READ_4(sc, CXM_REG_SPU) & CXM_MASK_SPU_ENABLE); + + /* Wait for 1 second */ + DELAY(1000000); + + /* Enable VPU */ + CSR_WRITE_4(sc, CXM_REG_VPU, + CSR_READ_4(sc, CXM_REG_VPU) + & (sc->type == cxm_iTVC15_type + ? CXM_MASK_VPU_ENABLE15 + : CXM_MASK_VPU_ENABLE16)); + + /* Wait for 1 second */ + DELAY(1000000); + + /* Locate encoder mailbox */ + mailbox = CXM_MEM_ENC; + for (i = 0; i < CXM_MEM_ENC_SIZE; i += 0x100) + if (CSR_READ_4(sc, mailbox + i) == 0x12345678 + && CSR_READ_4(sc, mailbox + i + 4) == 0x34567812 + && CSR_READ_4(sc, mailbox + i + 8) == 0x56781234 + && CSR_READ_4(sc, mailbox + i + 12) == 0x78123456) + break; + + if (i >= CXM_MEM_ENC_SIZE) + return -1; + + sc->enc_mbx = mailbox + i + 16; + + /* Locate decoder mailbox */ + if (sc->type == cxm_iTVC15_type) { + mailbox = CXM_MEM_DEC; + for (i = 0; i < CXM_MEM_DEC_SIZE; i += 0x100) + if (CSR_READ_4(sc, mailbox + i) == 0x12345678 + && CSR_READ_4(sc, mailbox + i + 4) == 0x34567812 + && CSR_READ_4(sc, mailbox + i + 8) == 0x56781234 + && CSR_READ_4(sc, mailbox + i + 12) == 0x78123456) + break; + + if (i >= CXM_MEM_DEC_SIZE) + return -1; + + sc->dec_mbx = mailbox + i + 16; + } + + /* Get encoder firmware version */ + parameter = 0; + if (cxm_firmware_command_nosleep(sc, cxm_enc_mailbox, + CXM_FW_CMD_ENC_GET_FW_VER, + ¶meter, 1) < 0) + return -1; + + printf("%s: encoder firmware version %#x\n", + sc->name, (unsigned int)parameter); + + /* Get decoder firmware version */ + if (sc->type == cxm_iTVC15_type) { + parameter = 0; + if (cxm_firmware_command_nosleep(sc, cxm_dec_mailbox, + CXM_FW_CMD_DEC_GET_FW_VER, + ¶meter, 1) < 0) + return -1; + + printf("%s: decoder firmware version %#x\n", + sc->name, (unsigned int)parameter); + } + + return 0; + } + + + static int + cxm_configure_encoder( struct cxm_softc *sc ) + { + int fps; + unsigned int i; + u_int32_t parameters[12]; + const struct cxm_codec_profile *cpp; + + fps = cxm_saa7115_detected_fps(sc); + + if (fps < 0) + return -1; + + if (sc->profile->fps != fps) { + + /* + * Pick a profile with the correct fps using the chosen + * width to decide between the VCD, SVCD, or DVD profiles. + */ + + for (i = 0; i < NUM_ELEMENTS(codec_profiles); i++) + if (codec_profiles[i]->fps == fps + && codec_profiles[i]->width == sc->profile->width) + break; + + if (i >= NUM_ELEMENTS(codec_profiles)) + return -1; + + sc->profile = codec_profiles[i]; + } + + cpp = sc->profile; + + if (cxm_saa7115_configure_scaler(sc, + cpp->width, cpp->source_height) < 0) + return -1; + + /* assign dma block len */ + parameters[0] = 1; /* Transfer block size = 1 */ + parameters[1] = 1; /* Units = 1 (frames) */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_DMA_BLOCKLEN, + parameters, 2) != 0) + return -1; + + + /* assign program index info */ + parameters[0] = 0; /* Picture mask = 0 (don't generate index) */ + parameters[1] = 0; /* Num_req = 0 */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_PGM_INDEX_INFO, + parameters, 2) != 0) + return -1; + + /* assign stream type */ + parameters[0] = cpp->stream_type; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_STREAM_TYPE, + parameters, 1) != 0) + return -1; + + /* assign output port */ + parameters[0] = 0; /* 0 (Memory) */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_OUTPUT_PORT, + parameters, 1) != 0) + return -1; + + /* assign framerate */ + parameters[0] = cpp->fps == 30 ? 0 : 1; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_FRAME_RATE, + parameters, 1) != 0) + return -1; + + /* assign frame size */ + parameters[0] = cpp->height; + parameters[1] = cpp->width; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_FRAME_SIZE, + parameters, 2) != 0) + return -1; + + /* assign aspect ratio */ + parameters[0] = cpp->aspect; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_ASPECT_RATIO, + parameters, 1) != 0) + return -1; + + /* assign bitrates */ + parameters[0] = cpp->bitrate.mode; + parameters[1] = cpp->bitrate.average; + parameters[2] = cpp->bitrate.peak / 400; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_BITRATES, + parameters, 3) != 0) + return -1; + + /* assign gop closure */ + parameters[0] = cpp->gop.closure; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_GOP_CLOSURE, + parameters, 1) != 0) + return -1; + + /* assign gop properties */ + parameters[0] = cpp->gop.frames; + parameters[1] = cpp->gop.bframes; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_GOP_PROPERTIES, + parameters, 2) != 0) + return -1; + + /* assign 3 2 pulldown */ + parameters[0] = cpp->pulldown; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_3_2_PULLDOWN, + parameters, 1) != 0) + return -1; + + /* assign dnr filter mode */ + parameters[0] = cpp->dnr.mode; + parameters[1] = cpp->dnr.type; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_DNR_FILTER_MODE, + parameters, 2) != 0) + return -1; + + /* assign dnr filter props */ + parameters[0] = cpp->dnr.spatial; + parameters[1] = cpp->dnr.temporal; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_DNR_FILTER_PROPERTIES, + parameters, 2) != 0) + return -1; + + /* assign audio properties */ + parameters[0] = cpp->audio; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_AUDIO_PROPERTIES, + parameters, 1) != 0) + return -1; + + /* assign coring levels */ + parameters[0] = 0; /* luma_h */ + parameters[1] = 255; /* luma_l */ + parameters[2] = 0; /* chroma_h */ + parameters[3] = 255; /* chroma_l */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_CORING_LEVELS, + parameters, 4) != 0) + return -1; + + /* assign spatial filter type */ + parameters[0] = 3; /* Luminance filter = 3 (2D H/V Separable) */ + parameters[1] = 1; /* Chrominance filter = 1 (1D Horizontal) */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_SPATIAL_FILTER_TYPE, + parameters, 2) != 0) + return -1; + + /* assign frame drop rate */ + parameters[0] = 0; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_FRAME_DROP_RATE, + parameters, 1) != 0) + return -1; + + /* assign placeholder */ + parameters[0] = 0; /* type = 0 (Extension / UserData) */ + parameters[1] = 0; /* period */ + parameters[2] = 0; /* size_t */ + parameters[3] = 0; /* arg0 */ + parameters[4] = 0; /* arg1 */ + parameters[5] = 0; /* arg2 */ + parameters[6] = 0; /* arg3 */ + parameters[7] = 0; /* arg4 */ + parameters[8] = 0; /* arg5 */ + parameters[9] = 0; /* arg6 */ + parameters[10] = 0; /* arg7 */ + parameters[11] = 0; /* arg8 */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_PLACEHOLDER, + parameters, 12) != 0) + return -1; + + /* assign number of lines in fields 1 and 2 */ + parameters[0] = cpp->source_height / 2; + parameters[1] = cpp->source_height / 2; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ASSIGN_NUM_VSYNC_LINES, + parameters, 2) != 0) + return -1; + + return 0; + } + + + static int + cxm_start_encoder( struct cxm_softc *sc ) + { + u_int32_t parameters[4]; + u_int32_t subtype; + u_int32_t type; + + if (sc->encoding) + return 0; + + if (cxm_configure_encoder(sc) < 0) + return -1; + + /* Clear pending encoder interrupts (which are currently masked) */ + CSR_WRITE_4(sc, CXM_REG_IRQ_STATUS, CXM_IRQ_ENC); + + /* Enable event notification */ + parameters[0] = 0; /* Event = 0 (refresh encoder input) */ + parameters[1] = 1; /* Notification = 1 (enable) */ + parameters[2] = 0x10000000; /* Interrupt bit */ + parameters[3] = -1; /* Mailbox = -1 (no mailbox) */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ENC_EVENT_NOTIFICATION, + parameters, 4) != 0) + return -1; + + if (cxm_saa7115_mute(sc) < 0) + return -1; + if (cxm_msp_mute(sc) < 0) + return -1; + + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_INITIALIZE_VIDEO_INPUT, + NULL, 0) < 0) + return -1; + + if (cxm_saa7115_unmute(sc) < 0) + return -1; + if (cxm_msp_unmute(sc) < 0) + return -1; + + /* Wait for 100ms */ + (void)tsleep(&sc->encoding, PWAIT, "cxmce", hz / 10); + + type = CXM_FW_CAPTURE_STREAM_TYPE_MPEG; + subtype = CXM_FW_CAPTURE_STREAM_PCM_AUDIO + | (sc->source == cxm_fm_source + ? 0 : CXM_FW_CAPTURE_STREAM_YUV); + + /* Start the encoder */ + parameters[0] = type; + parameters[1] = subtype; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_BEGIN_CAPTURE, parameters, 2) != 0) + return -1; + + sc->enc_pool.offset = 0; + sc->enc_pool.read = 0; + sc->enc_pool.write = 0; + + sc->encoding_eos = 0; + + sc->encoding = 1; + + /* Enable interrupts */ + sc->irq_mask &= ~CXM_IRQ_ENC; + CSR_WRITE_4(sc, CXM_REG_IRQ_MASK, sc->irq_mask); + + return 0; + } + + + static int + cxm_stop_encoder( struct cxm_softc *sc ) + { + u_int32_t parameters[4]; + u_int32_t subtype; + u_int32_t type; + intrmask_t s; + + if (! sc->encoding ) + return 0; + + type = CXM_FW_CAPTURE_STREAM_TYPE_MPEG; + subtype = CXM_FW_CAPTURE_STREAM_PCM_AUDIO + | (sc->source == cxm_fm_source + ? 0 : CXM_FW_CAPTURE_STREAM_YUV); + + /* Stop the encoder */ + parameters[0] = 0; /* When = 0 (end of GOP) */ + parameters[1] = type; + parameters[2] = subtype; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_END_CAPTURE, parameters, 3) != 0) + return -1; + + /* Wait for up to 1 second */ + s = spltty(); + if (! sc->encoding_eos ) + (void)tsleep(&sc->encoding_eos, PWAIT, "cxmeos", hz); + splx(s); + + if (! sc->encoding_eos ) + printf("%s: missing encoder EOS\n", sc->name); + + /* Disable event notification */ + parameters[0] = 0; /* Event = 0 (refresh encoder input) */ + parameters[1] = 0; /* Notification = 0 (disable) */ + parameters[2] = 0x10000000; /* Interrupt bit */ + parameters[3] = -1; /* Mailbox = -1 (no mailbox) */ + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_ENC_EVENT_NOTIFICATION, + parameters, 4) != 0) + return -1; + + /* Disable interrupts */ + sc->irq_mask |= CXM_IRQ_ENC; + CSR_WRITE_4(sc, CXM_REG_IRQ_MASK, sc->irq_mask); + + sc->encoding = 0; + + return 0; + } + + + static int + cxm_pause_encoder( struct cxm_softc *sc ) + { + u_int32_t parameter; + + /* Pause the encoder */ + parameter = 0; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_PAUSE_ENCODER, ¶meter, 1) != 0) + return -1; + + return 0; + } + + + static int + cxm_unpause_encoder( struct cxm_softc *sc ) + { + u_int32_t parameter; + + /* Unpause the encoder */ + parameter = 1; + if (cxm_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_PAUSE_ENCODER, ¶meter, 1) != 0) + return -1; + + return 0; + } + + + static void + cxm_encoder_dma_discard( struct cxm_softc *sc ) + { + u_int32_t parameters[3]; + + /* Discard the DMA request */ + parameters[0] = 0; + parameters[1] = 0; + parameters[2] = 0; + if (cxm_queue_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_SCHED_DMA_TO_HOST, + parameters, 3) == -1) { + printf("%s: failed to discard encoder dma request\n", + sc->name); + return; + } + + sc->encoding_dma = -1; + } + + + static void + cxm_encoder_dma_done( struct cxm_softc *sc ) + { + int buffers_pending; + u_int32_t status; + intrmask_t s; + + if (! sc->encoding_dma) { + printf("%s: encoder dma not already in progress\n", + sc->name); + return; + } + + buffers_pending = sc->encoding_dma; + sc->encoding_dma = 0; + + if (buffers_pending < 0) + return; + + status = CSR_READ_4(sc, CXM_REG_DMA_STATUS) & 0x0000000f; + + if ((status + & (CXM_DMA_ERROR_LIST | CXM_DMA_ERROR_WRITE | CXM_DMA_SUCCESS)) + != CXM_DMA_SUCCESS) { + printf("%s: encoder dma status %#x\n", + sc->name, (unsigned int)status); + return; + } + + /* Update the books (spl is used since mutex is not available) */ + s = spltty(); + sc->enc_pool.write = (sc->enc_pool.write + buffers_pending) + % CXM_SG_BUFFERS; + splx(s); + + /* wakeup anyone waiting for data */ + wakeup(&sc->enc_pool.read); + + /* wakeup anyone polling for data */ + selwakeup(&sc->enc_sel); + } + + + static void + cxm_encoder_dma_request( struct cxm_softc *sc ) + { + int buffers_free; + int buffers_pending; + unsigned int i; + unsigned int mailbox; + u_int32_t parameters[CXM_MBX_MAX_PARAMETERS]; + u_int32_t type; + size_t request_offset; + size_t request_size; + size_t sg_size; + intrmask_t s; + + if (sc->encoding_dma) { + printf("%s: encoder dma already in progress\n", + sc->name); + cxm_encoder_dma_discard(sc); + return; + } + + mailbox = sc->enc_mbx + + CXM_MBX_FW_DMA_MAILBOX * sizeof(struct cxm_mailbox); + + for (i = 0; i < CXM_MBX_MAX_PARAMETERS; i++) + parameters[i] + = CSR_READ_4(sc, + mailbox + + offsetof(struct cxm_mailbox, parameters) + + i * sizeof(u_int32_t)); + + type = parameters[0]; + + switch (type) { + case 0: /* MPEG */ + request_offset = parameters[1]; + request_size = parameters[2]; + break; + + case 1: /* YUV */ + case 2: /* PCM (audio) */ + case 3: /* VBI */ + default: + printf("%s: encoder dma type %#x unsupported\n", + sc->name, (unsigned int)type); + cxm_encoder_dma_discard(sc); + return; + } + + if (! request_size ) { + printf("%s: encoder dma size is zero\n", sc->name); + cxm_encoder_dma_discard(sc); + return; + } + + /* + * Determine the number of buffers free at this * instant * + * taking into consideration that the ring buffer wraps. + */ + s = spltty(); + buffers_free = sc->enc_pool.read - sc->enc_pool.write; + if (buffers_free <= 0) + buffers_free += CXM_SG_BUFFERS; + splx(s); + + /* + * Build the scatter / gather list taking in + * consideration that the ring buffer wraps, + * at least one free buffer must always be + * present to mark the end of the ring buffer, + * and each transfer must be a multiple of + * 256. + */ + + if (((request_size + 0x000000ff) & 0xffffff00) + > ((buffers_free - 1) * CXM_SG_SEGMENT)) { + printf("%s: encoder dma not enough buffer space free\n", + sc->name); + cxm_encoder_dma_discard(sc); + return; + } + + sg_size = 0; + + for (buffers_pending = 0, i = sc->enc_pool.write; + sg_size < request_size; + buffers_pending++, i = (i + 1) % CXM_SG_BUFFERS) { + sc->enc_pool.bufs[i].size = (request_size - sg_size) + > CXM_SG_SEGMENT + ? CXM_SG_SEGMENT + : (request_size - sg_size); + sc->enc_pool.bufs[i].byte_order = cxm_device_byte_order; + + sc->enc_sg.vaddr[buffers_pending].src + = request_offset + sg_size; + sc->enc_sg.vaddr[buffers_pending].dst + = sc->enc_pool.bufs[i].baddr; + sc->enc_sg.vaddr[buffers_pending].size + = (sc->enc_pool.bufs[i].size + 0x000000ff) & 0xffffff00; + + sg_size += sc->enc_sg.vaddr[buffers_pending].size; + } + + /* Mark the last transfer in the list */ + sc->enc_sg.vaddr[buffers_pending - 1].size |= 0x80000000; + + /* Schedule the DMA */ + parameters[0] = sc->enc_sg.baddr; + parameters[1] = buffers_pending * sizeof(sc->enc_sg.vaddr[0]); + parameters[2] = type; + if (cxm_queue_firmware_command(sc, cxm_enc_mailbox, + CXM_FW_CMD_SCHED_DMA_TO_HOST, + parameters, 3) == -1) { + printf("%s: failed to schedule encoder dma request\n", + sc->name); + return; + } + + /* + * Record the number of pending buffers for the + * benefit of cxm_encoder_dma_done. Doing this + * after queuing the command doesn't introduce + * a race condition since we're already in the + * interrupt handler. + */ + + sc->encoding_dma = buffers_pending; + } + + + static void + cxm_mapmem(void *arg, bus_dma_segment_t *segs, int nseg, int error) + { + bus_addr_t *busaddrp; + + /* + * Only the first bus space address is needed + * since it's known that the memory is physically + * contiguous due to bus_dmamem_alloc. + */ + + busaddrp = (bus_addr_t *)arg; + *busaddrp = segs->ds_addr; + } + + + /* + * the boot time probe routine. + */ + static int + cxm_probe( device_t dev ) + { + struct cxm_dev *t; + + t = cxm_devs; + + while(t->name != NULL) { + if ((pci_get_vendor(dev) == t->vid) && + (pci_get_device(dev) == t->did)) { + device_set_desc(dev, t->name); + return 0; + } + t++; + } + + return ENXIO; + } + + + /* + * the attach routine. + */ + static int + cxm_attach( device_t dev ) + { + int error; + int rid; + int unit; + unsigned int i; + u_int32_t command; + struct cxm_softc *sc; + + /* Get the device data */ + sc = device_get_softc(dev); + unit = device_get_unit(dev); + + sc->type = cxm_iTVC15_type; + switch(pci_get_device(dev)) { + case CXM_DEVICEID_CONEXANT_iTVC16: + sc->type = cxm_iTVC16_type; + break; + + default: + break; + } + + /* build the device name */ + snprintf(sc->name, sizeof(sc->name), "cxm%d",unit); + + /* + * Enable bus mastering and memory mapped I/O. + */ + pci_enable_busmaster(dev); + pci_enable_io(dev, SYS_RES_MEMORY); + command = pci_read_config(dev, PCIR_COMMAND, 4); + + if (! (command & PCIM_CMD_MEMEN) ) { + device_printf(dev, "failed to enable memory mappings\n"); + error = ENXIO; + goto fail; + } + + /* + * Map control/status registers. + */ + rid = CXM_RID; + sc->mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, + 0, ~0, 1, RF_ACTIVE); + + if (! sc->mem_res ) { + device_printf(dev, "could not map memory\n"); + error = ENXIO; + goto fail; + } + + sc->btag = rman_get_bustag(sc->mem_res); + sc->bhandle = rman_get_bushandle(sc->mem_res); + + /* + * Attach the I2C bus. + */ + sc->cxm_iic = device_add_child(dev, "cxm_iic", unit); + + if (! sc->cxm_iic ) { + device_printf(dev, "could not add cxm_iic\n"); + error = ENXIO; + goto fail; + } + + error = device_probe_and_attach(sc->cxm_iic); + + if (error) { + device_printf(dev, "could not attach cxm_iic\n"); + goto fail; + } + + /* + * Initialize the tuner. + */ + if (cxm_tuner_init(sc) < 0) { + device_printf(dev, "could not initialize tuner\n"); + error = ENXIO; + goto fail; + } + + /* + * Initialize the SAA7115. + */ + if (cxm_saa7115_init(sc) < 0) { + device_printf(dev, "could not initialize video decoder\n"); + error = ENXIO; + goto fail; + } + + /* + * Initialize the MSP3400. + */ + if (cxm_msp_init(sc) < 0) { + device_printf(dev, "could not initialize audio decoder\n"); + error = ENXIO; + goto fail; + } + + /* + * Initialize the IR Remote. + */ + if (cxm_ir_init(sc) < 0) { + device_printf(dev, "could not initialize IR remote\n"); + error = ENXIO; + goto fail; + } + + sc->dec_mbx = -1; + sc->enc_mbx = -1; + + /* + * Disable the Conexant device. + * + * This is done * after * attaching the I2C bus so + * cxm_stop_hardware can mute the video and audio + * decoders. + */ + cxm_stop_hardware(sc); + + /* + * Allocate our interrupt. + */ + rid = 0; + sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, + 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE); + + if (sc->irq_res == NULL) { + device_printf(dev, "could not map interrupt\n"); + error = ENXIO; + goto fail; + } + + error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_TTY, + cxm_intr, sc, &sc->ih_cookie); + if (error) { + device_printf(dev, "could not setup irq\n"); + goto fail; + + } + + /* + * Allocate a DMA tag for the parent bus. + */ + error = bus_dma_tag_create(NULL, 1, 0, + BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, 1, + BUS_SPACE_MAXSIZE_32BIT, 0, + &sc->parent_dmat); + if (error) { + device_printf(dev, "could not create parent bus DMA tag\n"); + goto fail; + } + + /* + * Allocate a DMA tag for the encoder buffers. + */ + error = bus_dma_tag_create(sc->parent_dmat, 256, 0, + BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR, NULL, NULL, + CXM_SG_SEGMENT, 1, + BUS_SPACE_MAXSIZE_32BIT, 0, + &sc->enc_pool.dmat); + if (error) { + device_printf(dev, + "could not create encoder buffer DMA tag\n"); + goto fail; + } + + for (i = 0; i < CXM_SG_BUFFERS; i++) { + + /* + * Allocate the encoder buffer. + */ + error = bus_dmamem_alloc(sc->enc_pool.dmat, + (void **)&sc->enc_pool.bufs[i].vaddr, + BUS_DMA_NOWAIT, + &sc->enc_pool.bufs[i].dmamap); + if (error) { + device_printf(dev, + "could not allocate encoder buffer\n"); + goto fail; + } + + /* + * Map the encoder buffer. + */ + error = bus_dmamap_load(sc->enc_pool.dmat, + sc->enc_pool.bufs[i].dmamap, + sc->enc_pool.bufs[i].vaddr, + CXM_SG_SEGMENT, + cxm_mapmem, + &sc->enc_pool.bufs[i].baddr, 0); + if (error) { + device_printf(dev, "could not map encoder buffer\n"); + goto fail; + } + } + + /* + * Allocate a DMA tag for the scatter / gather list. + */ + error = bus_dma_tag_create(sc->parent_dmat, 1, 0, + BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR, NULL, NULL, + CXM_SG_BUFFERS + * sizeof(struct cxm_sg_entry), 1, + BUS_SPACE_MAXSIZE_32BIT, 0, + &sc->enc_sg.dmat); + if (error) { + device_printf(dev, + "could not create scatter / gather DMA tag\n"); + goto fail; + } + + /* + * Allocate the scatter / gather list. + */ + error = bus_dmamem_alloc(sc->enc_sg.dmat, (void **)&sc->enc_sg.vaddr, + BUS_DMA_NOWAIT, &sc->enc_sg.dmamap); + if (error) { + device_printf(dev, + "could not allocate scatter / gather list\n"); + goto fail; + } + + /* + * Map the scatter / gather list. + */ + error = bus_dmamap_load(sc->enc_sg.dmat, sc->enc_sg.dmamap, + sc->enc_sg.vaddr, + CXM_SG_BUFFERS * sizeof(struct cxm_sg_entry), + cxm_mapmem, &sc->enc_sg.baddr, 0); + if (error) { + device_printf(dev, "could not map scatter / gather list\n"); + goto fail; + } + + /* + * Initialize the hardware. + */ + if (cxm_init_hardware(sc) < 0) { + device_printf(dev, "could not initialize hardware\n"); + error = ENXIO; + goto fail; + } + + sc->profile = &dvd_ntsc_profile; + + sc->source = cxm_tuner_source; + + /* make the device entries */ + sc->cxm_dev = make_dev(&cxm_cdevsw, unit, + 0, 0, 0444, "cxm%d", unit); + + return 0; + + fail: + if (sc->cxm_iic) { + bus_generic_detach(dev); + device_delete_child(dev, sc->cxm_iic); + } + + if (sc->enc_sg.baddr) + bus_dmamap_unload(sc->enc_sg.dmat, sc->enc_sg.dmamap); + if (sc->enc_sg.vaddr) + bus_dmamem_free(sc->enc_sg.dmat, sc->enc_sg.vaddr, + sc->enc_sg.dmamap); + if (sc->enc_sg.dmat) + bus_dma_tag_destroy(sc->enc_sg.dmat); + + for (i = 0; i < CXM_SG_BUFFERS; i++) { + if (sc->enc_pool.bufs[i].baddr) + bus_dmamap_unload(sc->enc_pool.dmat, + sc->enc_pool.bufs[i].dmamap); + if (sc->enc_pool.bufs[i].vaddr) + bus_dmamem_free(sc->enc_pool.dmat, + sc->enc_pool.bufs[i].vaddr, + sc->enc_pool.bufs[i].dmamap); + } + + if (sc->enc_pool.dmat) + bus_dma_tag_destroy(sc->enc_pool.dmat); + + if (sc->parent_dmat) + bus_dma_tag_destroy(sc->parent_dmat); + + if (sc->ih_cookie) + bus_teardown_intr(dev, sc->irq_res, sc->ih_cookie); + if (sc->irq_res) + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); + if (sc->mem_res) + bus_release_resource(dev, SYS_RES_MEMORY, CXM_RID, sc->mem_res); + + return error; + } + + /* + * the detach routine. + */ + static int + cxm_detach( device_t dev ) + { + unsigned int i; + struct cxm_softc *sc; + + /* Get the device data */ + sc = device_get_softc(dev); + + /* Disable the Conexant device. */ + cxm_stop_hardware(sc); + + /* Unregister the /dev/cxmN device. */ + destroy_dev(sc->cxm_dev); + + /* Detach the I2C bus. */ + bus_generic_detach(dev); + device_delete_child(dev, sc->cxm_iic); + + /* + * Deallocate resources. + */ + bus_dmamap_unload(sc->enc_sg.dmat, sc->enc_sg.dmamap); + bus_dmamem_free(sc->enc_sg.dmat, sc->enc_sg.vaddr, sc->enc_sg.dmamap); + + bus_dma_tag_destroy(sc->enc_sg.dmat); + + for (i = 0; i < CXM_SG_BUFFERS; i++) { + bus_dmamap_unload(sc->enc_pool.dmat, + sc->enc_pool.bufs[i].dmamap); + bus_dmamem_free(sc->enc_pool.dmat, sc->enc_pool.bufs[i].vaddr, + sc->enc_pool.bufs[i].dmamap); + } + + bus_dma_tag_destroy(sc->enc_pool.dmat); + + bus_dma_tag_destroy(sc->parent_dmat); + + bus_teardown_intr(dev, sc->irq_res, sc->ih_cookie); + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); + bus_release_resource(dev, SYS_RES_MEMORY, CXM_RID, sc->mem_res); + + return 0; + } + + /* + * the shutdown routine. + */ + static int + cxm_shutdown( device_t dev ) + { + struct cxm_softc *sc = device_get_softc(dev); + + /* Disable the Conexant device. */ + cxm_stop_hardware(sc); + + return 0; + } + + /* + * the interrupt routine. + */ + static void + cxm_intr( void *arg ) + { + u_int32_t status; + struct cxm_softc *sc; + + /* Get the device data */ + sc = (struct cxm_softc *)arg; + + status = CSR_READ_4(sc, CXM_REG_IRQ_STATUS); + + status &= ~sc->irq_mask; + + if (! status ) + return; + + /* Process DMA done before handling a new DMA request or EOS */ + if (status & CXM_IRQ_ENC_DMA_DONE) + cxm_encoder_dma_done(sc); + + if (status & CXM_IRQ_ENC_DMA_REQUEST) + cxm_encoder_dma_request(sc); + + if (status & CXM_IRQ_ENC_EOS) { + sc->encoding_eos = 1; + wakeup(&sc->encoding_eos); + } + + CSR_WRITE_4(sc, CXM_REG_IRQ_STATUS, status); + } + + + static int + cxm_read_ivar( device_t dev, device_t child, int index, uintptr_t* val) + { + struct cxm_softc *sc; + + /* Get the device data */ + sc = device_get_softc(dev); + + switch (index) { + case CXM_IVAR_BHANDLE: + *val = sc->bhandle; + break; + + case CXM_IVAR_BTAG: + *val = sc->btag; + break; + + case CXM_IVAR_IICBUS: + *val = (uintptr_t)sc->iicbus; + break; + + default: + return ENOENT; + } + + return 0; + } + + + static int + cxm_write_ivar( device_t dev, device_t child, int index, uintptr_t val) + { + struct cxm_softc *sc; + + /* Get the device data */ + sc = device_get_softc(dev); + + switch (index) { + case CXM_IVAR_BHANDLE: + return EINVAL; + + case CXM_IVAR_BTAG: + return EINVAL; + + case CXM_IVAR_IICBUS: + if (sc->iicbus) + return EINVAL; + sc->iicbus = (device_t)val; + break; + + default: + return ENOENT; + } + + return 0; + } + + + /*--------------------------------------------------------- + ** + ** Conexant iTVC15 / iTVC16 character device driver routines + ** + **--------------------------------------------------------- + */ + + #define UNIT(x) ((x) & 0x0f) + #define FUNCTION(x) (x >> 4) + + /* + * + */ + int + cxm_open( dev_t dev, int flags, int fmt, struct proc *p ) + { + int unit; + struct cxm_softc *sc; + + unit = UNIT( minor(dev) ); + + /* Get the device data */ + sc = (struct cxm_softc*)devclass_get_softc(cxm_devclass, unit); + if (sc == NULL) { + /* the device is no longer valid/functioning */ + return ENXIO; + } + + if (sc->is_opened) + return EBUSY; + + sc->is_opened = 1; + + /* Record that the device is now busy */ + device_busy(devclass_get_device(cxm_devclass, unit)); + + return 0; + } + + + /* + * + */ + int + cxm_close( dev_t dev, int flags, int fmt, struct proc *p ) + { + int unit; + struct cxm_softc *sc; + + unit = UNIT( minor(dev) ); + + /* Get the device data */ + sc = (struct cxm_softc*)devclass_get_softc(cxm_devclass, unit); + if (sc == NULL) { + /* the device is no longer valid/functioning */ + return ENXIO; + } + + if (cxm_stop_encoder(sc) < 0) + return ENXIO; + + sc->enc_pool.offset = 0; + sc->enc_pool.read = 0; + sc->enc_pool.write = 0; + + device_unbusy(devclass_get_device(cxm_devclass, unit)); + + sc->is_opened = 0; + + return 0; + } + + + /* + * + */ + int + cxm_read( dev_t dev, struct uio *uio, int flag ) + { + int buffers_available; + int buffers_read; + int error; + int unit; + unsigned int i; + u_int32_t *ptr; + size_t nbytes; + size_t offset; + struct cxm_softc *sc; + intrmask_t s; + + unit = UNIT( minor(dev) ); + + /* Get the device data */ + sc = (struct cxm_softc*)devclass_get_softc(cxm_devclass, unit); + if (sc == NULL) { + /* the device is no longer valid/functioning */ + return ENXIO; + } + + /* Only trigger the encoder if the ring buffer is empty */ + if (! sc->encoding && sc->enc_pool.read == sc->enc_pool.write) { + if (cxm_start_encoder(sc) < 0) + return ENXIO; + if (flag & IO_NDELAY) + return EWOULDBLOCK; + } + + buffers_available = 0; + + s = spltty(); + while (sc->enc_pool.read == sc->enc_pool.write) { + error = tsleep(&sc->enc_pool.read, PZERO | PCATCH, "cmxrd", 0); + if (error) { + splx(s); + return error; + } + } + + /* + * Determine the number of buffers available at this * instant * + * taking in consideration that the ring buffer wraps. + */ + buffers_available = sc->enc_pool.write - sc->enc_pool.read; + if (buffers_available < 0) + buffers_available += CXM_SG_BUFFERS; + splx(s); + + offset = sc->enc_pool.offset; + + for (buffers_read = 0, i = sc->enc_pool.read; + buffers_read != buffers_available && uio->uio_resid; + buffers_read++, i = (i + 1) % CXM_SG_BUFFERS) { + + /* Swap the byte order if it hasn't already been done */ + if (sc->enc_pool.bufs[i].byte_order == cxm_device_byte_order) { + for (nbytes = 0, + ptr = (u_int32_t *)sc->enc_pool.bufs[i].vaddr; + nbytes != sc->enc_pool.bufs[i].size; + nbytes += sizeof(*ptr), ptr++) + *ptr = bswap32(*ptr); + sc->enc_pool.bufs[i].byte_order = cxm_host_byte_order; + } + + nbytes = sc->enc_pool.bufs[i].size - offset; + + /* Don't transfer more than requested */ + if (nbytes > uio->uio_resid) + nbytes = uio->uio_resid; + + error = uiomove(sc->enc_pool.bufs[i].vaddr + offset, + nbytes, uio); + if (error) + return error; + + offset += nbytes; + + /* Handle a partial read of a buffer */ + if (! uio->uio_resid && offset != sc->enc_pool.bufs[i].size) + break; + + offset = 0; + } + + sc->enc_pool.offset = offset; + + /* Update the books (spl is used since mutex is not available) */ + s = spltty(); + sc->enc_pool.read = (sc->enc_pool.read + buffers_read) + % CXM_SG_BUFFERS; + splx(s); + + return 0; + } + + + /* + * + */ + int + cxm_ioctl( dev_t dev, unsigned long cmd, caddr_t arg, + int flag, struct proc* pr ) + { + int fps; + int unit; + int status; + unsigned int i; + unsigned long freq; + struct cxm_softc *sc; + enum cxm_source source; + struct bktr_capture_area *cap; + struct bktr_remote *remote; + + unit = UNIT( minor(dev) ); + + /* Get the device data */ + sc = (struct cxm_softc*)devclass_get_softc(cxm_devclass, unit); + if (sc == NULL) { + /* the device is no longer valid/functioning */ + return ENXIO; + } + + switch (cmd) { + case METEORCAPTUR: + switch (*(int *) arg) { + case METEOR_CAP_CONTINOUS: + if (cxm_start_encoder(sc) < 0) + return ENXIO; + break; + + case METEOR_CAP_STOP_CONT: + if (cxm_stop_encoder(sc) < 0) + return ENXIO; + break; + + default: + return EINVAL; + } + break; + + case BT848_GCAPAREA: + cap = (struct bktr_capture_area *)arg; + cap->x_offset = 0; + cap->y_offset = 0; + cap->x_size = sc->profile->width; + cap->y_size = sc->profile->height; + break; + + case BT848_SCAPAREA: + if (sc->encoding) + return EBUSY; + + cap = (struct bktr_capture_area *)arg; + if (cap->x_offset || cap->y_offset) + return EINVAL; + + /* + * Setting the width and height has the side effect of + * chosing between the VCD, SVCD, and DVD profiles. + */ + + for (i = 0; i < NUM_ELEMENTS(codec_profiles); i++) + if (codec_profiles[i]->width == cap->x_size + && codec_profiles[i]->height == cap->y_size) + break; + + if (i >= NUM_ELEMENTS(codec_profiles)) + return EINVAL; + + sc->profile = codec_profiles[i]; + break; + + case BT848GFMT: + switch (cxm_saa7115_detected_format(sc)) { + case cxm_ntsc_60hz_source_format: + *(unsigned long *)arg = BT848_IFORM_F_NTSCM; + break; + + case cxm_pal_50hz_source_format: + *(unsigned long *)arg = BT848_IFORM_F_PALBDGHI; + break; + + case cxm_secam_50hz_source_format: + *(unsigned long *)arg = BT848_IFORM_F_SECAM; + break; + + case cxm_pal_60hz_source_format: + *(unsigned long *)arg = BT848_IFORM_F_PALM; + break; + + case cxm_bw_50hz_source_format: + case cxm_bw_60hz_source_format: + case cxm_ntsc_50hz_source_format: + *(unsigned long *)arg = BT848_IFORM_F_AUTO; + break; + + default: + return ENXIO; + } + break; + + case METEORGFMT: + switch (cxm_saa7115_detected_format(sc)) { + case cxm_ntsc_60hz_source_format: + *(unsigned long *)arg = METEOR_FMT_NTSC; + break; + + case cxm_pal_50hz_source_format: + *(unsigned long *)arg = METEOR_FMT_PAL; + break; + + case cxm_secam_50hz_source_format: + *(unsigned long *)arg = METEOR_FMT_SECAM; + break; + + case cxm_bw_50hz_source_format: + case cxm_bw_60hz_source_format: + case cxm_ntsc_50hz_source_format: + case cxm_pal_60hz_source_format: + *(unsigned long *)arg = METEOR_FMT_AUTOMODE; + break; + + default: + return ENXIO; + } + break; + + case METEORGFPS: + fps = cxm_saa7115_detected_fps(sc); + + if (fps < 0) + return ENXIO; + + *(unsigned short *)arg = fps; + break; + + case METEORGINPUT: + switch (sc->source) { + case cxm_tuner_source: + *(unsigned long *)arg = METEOR_INPUT_DEV1; + break; + + case cxm_line_in_source_composite: + *(unsigned long *)arg = METEOR_INPUT_DEV2; + break; + + case cxm_line_in_source_svideo: + *(unsigned long *)arg = METEOR_INPUT_DEV_SVIDEO; + break; + + default: + return ENXIO; + } + break; + + case METEORSINPUT: + source = cxm_unknown_source; + switch (*(unsigned long *)arg & 0xf000) { + case METEOR_INPUT_DEV1: + source = cxm_tuner_source; + break; + + case METEOR_INPUT_DEV2: + source = cxm_line_in_source_composite; + break; + + case METEOR_INPUT_DEV_SVIDEO: + source = cxm_line_in_source_svideo; + break; + + default: + return EINVAL; + } + + if (sc->encoding) { + + /* + * Switching between audio + video and audio only + * subtypes isn't supported while encoding. + */ + + if (source != sc->source + && (source == cxm_fm_source + || sc->source == cxm_fm_source)) + return EBUSY; + } + + if (cxm_pause_encoder(sc) < 0) + return ENXIO; + + sc->source = cxm_unknown_source; + + if (cxm_saa7115_select_source(sc, source) < 0) + return ENXIO; + if (cxm_msp_select_source(sc, source) < 0) + return ENXIO; + + sc->source = source; + + if (cxm_saa7115_wait_for_lock(sc) < 0) + return EINVAL; + if (cxm_msp_autodetect_standard(sc) < 0) + return EINVAL; + if (cxm_msp_wait_for_lock(sc) < 0) + return EINVAL; + if (cxm_msp_unmute(sc) < 0) + return EINVAL; + + if (cxm_unpause_encoder(sc) < 0) + return ENXIO; + break; + + case RADIO_GETFREQ: + /* Convert from kHz to MHz * 100 */ + freq = sc->tuner_freq / 10; + + *(unsigned int *)arg = freq; + break; + + case RADIO_SETFREQ: + if (sc->source == cxm_fm_source) + if (cxm_pause_encoder(sc) < 0) + return ENXIO; + + /* Convert from MHz * 100 to kHz */ + freq = *(unsigned int *)arg * 10; + + if (cxm_tuner_select_frequency(sc, cxm_tuner_fm_freq_type, + freq) < 0) + return ENXIO; + + if (cxm_tuner_wait_for_lock(sc) < 0) + return EINVAL; + + if (sc->source == cxm_fm_source) { + if (cxm_msp_wait_for_lock(sc) < 0) + return EINVAL; + if (cxm_unpause_encoder(sc) < 0) + return ENXIO; + } + break; + + case TVTUNER_GETAFC: + *(int *)arg = sc->tuner_afc; + break; + + case TVTUNER_SETAFC: + sc->tuner_afc = (*(int *)arg != 0); + break; + + case TVTUNER_SETCHNL: + if (sc->source == cxm_tuner_source) + if (cxm_pause_encoder(sc) < 0) + return ENXIO; + + if (cxm_tuner_select_channel(sc, *(unsigned int *)arg) < 0) + return ENXIO; + + if (sc->tuner_afc) + if (cxm_tuner_apply_afc(sc) < 0) + return EINVAL; + + if (cxm_tuner_wait_for_lock(sc) < 0) + return EINVAL; + + if (sc->source == cxm_tuner_source) { + if (cxm_saa7115_wait_for_lock(sc) < 0) + return EINVAL; + if (cxm_msp_autodetect_standard(sc) < 0) + return EINVAL; + if (cxm_msp_wait_for_lock(sc) < 0) + return EINVAL; + if (cxm_msp_unmute(sc) < 0) + return EINVAL; + if (cxm_unpause_encoder(sc) < 0) + return ENXIO; + } + break; + + case TVTUNER_GETFREQ: + /* Convert from kHz to MHz * 16 */ + freq = (sc->tuner_freq * 16) / 1000; + + *(unsigned int *)arg = freq; + break; + + case TVTUNER_SETFREQ: + if (sc->source == cxm_tuner_source) + if (cxm_pause_encoder(sc) < 0) + return ENXIO; + + /* Convert from MHz * 16 to kHz */ + freq = (*(unsigned int *)arg * 1000) / 16; + + if (cxm_tuner_select_frequency(sc, cxm_tuner_tv_freq_type, + freq) < 0) + return ENXIO; + + if (cxm_tuner_wait_for_lock(sc) < 0) + return EINVAL; + + if (sc->source == cxm_tuner_source) { + if (cxm_saa7115_wait_for_lock(sc) < 0) + return EINVAL; + if (cxm_msp_autodetect_standard(sc) < 0) + return EINVAL; + if (cxm_msp_wait_for_lock(sc) < 0) + return EINVAL; + if (cxm_msp_unmute(sc) < 0) + return EINVAL; + if (cxm_unpause_encoder(sc) < 0) + return ENXIO; + } + break; + + case TVTUNER_GETSTATUS: + status = cxm_tuner_status(sc); + if (status < 0) + return ENXIO; + *(unsigned long *)arg = status & 0xff; + break; + + case REMOTE_GETKEY: + remote = (struct bktr_remote *)arg; + if (cxm_ir_key(sc, (char *)remote, sizeof(*remote)) < 0) + return ENXIO; + break; + + default: + return ENOTTY; + } + + return 0; + } + + + int cxm_poll( dev_t dev, int events, struct proc *p) + { + int revents; + int unit; + struct cxm_softc *sc; + intrmask_t s; + + unit = UNIT( minor(dev) ); + + /* Get the device data */ + sc = (struct cxm_softc*)devclass_get_softc(cxm_devclass, unit); + if (sc == NULL) { + /* the device is no longer valid/functioning */ + return POLLHUP; + } + + revents = 0; + + s = spltty(); + if (events & (POLLIN | POLLRDNORM)) { + if (sc->enc_pool.read == sc->enc_pool.write) + selrecord(p, &sc->enc_sel); + else + revents = events & (POLLIN | POLLRDNORM); + } + splx(s); + + return revents; + } *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm.h Fri Nov 28 22:49:59 2003 *************** *** 0 **** --- 1,565 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Header file for the Conexant MPEG-2 Codec driver. + */ + + #define bswap32(X) ntohl(X) + + #define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array)) + + /* + * For simplicity several large buffers allocate during + * driver attachment which normally occurs early on + * (when large areas of memory are available) are used + * to move data to / from the card. It's not unusual + * for the memory allocation to fail due to fragmentation + * if the driver is loaded after the system has been + * running for a while. One solution is to allocate + * several PAGE_SIZE buffers instead, however it doesn't + * seem worth the trouble. + */ + enum cxm_byte_order { cxm_unknown_byte_order, + cxm_device_byte_order, cxm_host_byte_order }; + + struct cxm_buffer { + char *vaddr; + bus_addr_t baddr; + bus_dmamap_t dmamap; + size_t size; + enum cxm_byte_order byte_order; + }; + + #define CXM_SG_BUFFERS 50 + + struct cxm_buffer_pool { + bus_dma_tag_t dmat; + size_t offset; + volatile unsigned int read; + volatile unsigned int write; + struct cxm_buffer bufs[CXM_SG_BUFFERS]; + }; + + struct cxm_codec_profile { + const char *name; + u_int32_t stream_type; + u_int32_t fps; + u_int32_t width; + u_int32_t height; + u_int32_t source_height; + u_int32_t aspect; + u_int32_t pulldown; + struct { + u_int32_t mode; + u_int32_t average; + u_int32_t peak; + } bitrate; + struct { + u_int32_t closure; + u_int32_t frames; + u_int32_t bframes; + } gop; + struct { + u_int32_t mode; + u_int32_t type; + u_int32_t spatial; + u_int32_t temporal; + } dnr; + + /* + * Audio format encoding + * + * 7 6 5 4 3 2 1 0 + * + * 0 0 44.1 kHz + * 0 1 48 kHz + * 1 0 32 kHz + * + * 0 1 Layer 1 + * 1 0 Layer 2 + * 1 1 Layer 3 + * + * L1 / L2 + * 0 0 0 0 Free fmt + * 0 0 0 1 32k / 32k + * 0 0 1 0 64k / 48k + * 0 0 1 1 96k / 56k + * 0 1 0 0 128k / 64k + * 0 1 0 1 160k / 80k + * 0 1 1 0 192k / 96k + * 0 1 1 1 224k / 112k + * 1 0 0 0 256k / 128k + * 1 0 0 1 288k / 160k + * 1 0 1 0 320k / 192k + * 1 0 1 1 352k / 224k + * 1 1 0 0 384k / 256k + * 1 1 0 1 416k / 320k + * 1 1 1 0 448k / 384k + */ + + u_int32_t audio; + }; + + #define CXM_VENDORID_CONEXANT 0x4444 + #define CXM_DEVICEID_CONEXANT_iTVC15 0x0803 + #define CXM_DEVICEID_CONEXANT_iTVC16 0x0016 + + #define CXM_VENDORID_HAUPPAUGE 0x0070 + + struct cxm_dev { + u_int16_t vid; + u_int16_t did; + char *name; + }; + + #define CXM_MBX_FW_CMD_MAILBOX 0 + #define CXM_MBX_FW_CMD_MAILBOXES 6 + + #define CXM_MBX_FW_DMA_MAILBOX 9 + + #define CXM_MBX_MAX_PARAMETERS 16 + + /* Mailbox flags bit definitions */ + #define CXM_MBX_FLAG_DRV_DONE 0x00000002 + #define CXM_MBX_FLAG_FW_DONE 0x00000004 + #define CXM_MBX_FLAG_IN_USE 0x00000001 + + struct cxm_mailbox { + u_int32_t flags; + u_int32_t command; + u_int32_t result; + u_int32_t timeout; + u_int32_t parameters[CXM_MBX_MAX_PARAMETERS]; + } __attribute__ ((packed)); + + enum cxm_mailbox_name { cxm_unknown_mailbox, + cxm_dec_mailbox, cxm_enc_mailbox }; + + /* + * Scatter / gather is supported with the restriction + * that the size of each piece must be a multiple of + * 256 and less than 64k. + */ + #define CXM_SG_SEGMENT (0xff00 & ~(PAGE_SIZE - 1)) + + struct cxm_sg_entry { + u_int32_t src; + u_int32_t dst; + u_int32_t size; + } __attribute__ ((packed)); + + struct cxm_sg_list { + bus_dma_tag_t dmat; + struct cxm_sg_entry *vaddr; + bus_addr_t baddr; + bus_dmamap_t dmamap; + + }; + + enum cxm_source { cxm_unknown_source, cxm_fm_source, cxm_tuner_source, + cxm_line_in_source_composite, cxm_line_in_source_svideo }; + + enum cxm_source_format { cxm_unknown_source_format, + cxm_bw_50hz_source_format, + cxm_bw_60hz_source_format, + cxm_ntsc_50hz_source_format, + cxm_ntsc_60hz_source_format, + cxm_pal_50hz_source_format, + cxm_pal_60hz_source_format, + cxm_secam_50hz_source_format }; + + extern const struct cxm_tuner cxm_tuners[]; + + enum cxm_type { cxm_unknown_type, cxm_iTVC15_type, cxm_iTVC16_type }; + + /* + * Conexant iTVC15 / iTVC16 info structure, one per card installed. + */ + struct cxm_softc { + enum cxm_type type; + char name[10]; /* Device name and unit number */ + + struct resource *mem_res; /* Resource descriptor for registers */ + bus_space_tag_t btag; /* Bus space access functions */ + bus_space_handle_t bhandle; /* Bus space access functions */ + + struct resource *irq_res; /* Resource descriptor for interrupt */ + void *ih_cookie; /* Newbus interrupt handler cookie */ + + u_int32_t irq_mask; + + bus_dma_tag_t parent_dmat; + + struct cxm_buffer_pool enc_pool; + struct cxm_sg_list enc_sg; + struct selinfo enc_sel; + + unsigned int dec_mbx; + unsigned int enc_mbx; + + device_t cxm_iic; + device_t iicbus; + + const struct cxm_tuner *tuner; + const struct cxm_tuner_channels *tuner_channels; + int tuner_afc; + unsigned long tuner_freq; + + char msp_name[10]; + + const struct cxm_codec_profile *profile; + + enum cxm_source source; + + dev_t cxm_dev; /* Device entry for /dev/cxmN */ + + int is_opened; + + int encoding; + int encoding_dma; + volatile int encoding_eos; + }; + + /* + * Conexant iTVC15 / iTVC16 I2C info structure, one per card installed. + */ + struct cxm_iic_softc { + char name[10]; /* Device name and unit number */ + bus_space_tag_t btag; /* Bus space access functions */ + bus_space_handle_t bhandle; /* Bus space access functions */ + + device_t iicbb; + + }; + + /* + * List of IVARS available to the I2C device driver + */ + #define CXM_IVAR_BHANDLE 0 + #define CXM_IVAR_BTAG 1 + #define CXM_IVAR_IICBUS 2 + + /* + * Bus resource id + */ + #define CXM_RID PCIR_MAPS + + /* + * Access macros + */ + #define CSR_WRITE_4(sc, reg, val) \ + bus_space_write_4((sc)->btag, (sc)->bhandle, (reg), (val)) + #define CSR_WRITE_2(sc, reg, val) \ + bus_space_write_2((sc)->btag, (sc)->bhandle, (reg), val)) + #define CSR_WRITE_1(sc, reg, val) \ + bus_space_write_1((sc)->btag, (sc)->bhandle, (reg), val)) + #define CSR_READ_4(sc, reg) \ + bus_space_read_4((sc)->btag, (sc)->bhandle, (reg)) + #define CSR_READ_2(sc, reg) \ + bus_space_read_2((sc)->btag, (sc)->bhandle, (reg)) + #define CSR_READ_1(sc, reg) \ + bus_space_read_1((sc)->btag, (sc)->bhandle, (reg)) + + /* + * Decoder / encoder firmware + */ + extern const char cxm_dec_fw[]; + extern const char cxm_enc_fw[]; + + #define CXM_FW_SIZE (256 * 1024) + + /* + * Decoder / encoder memory offsets + */ + #define CXM_MEM_DEC 0x01000000 + #define CXM_MEM_ENC 0x00000000 + + #define CXM_MEM_DEC_SIZE 0x01000000 + #define CXM_MEM_ENC_SIZE 0x01000000 + + /* + * Register offsets + */ + #define CXM_REG_AO 0x2002d00 + #define CXM_REG_APU 0x200a064 + #define CXM_REG_DEC_SDRAM_PRECHARGE 0x20008fc + #define CXM_REG_DEC_SDRAM_REFRESH 0x20008f8 + #define CXM_REG_DMA_STATUS 0x2000004 + #define CXM_REG_ENC_SDRAM_PRECHARGE 0x20007fc + #define CXM_REG_ENC_SDRAM_REFRESH 0x20007f8 + #define CXM_REG_HW_BLOCKS 0x2009054 + #define CXM_REG_I2C_GETSCL 0x2007008 + #define CXM_REG_I2C_GETSDA 0x200700c + #define CXM_REG_I2C_SETSCL 0x2007000 + #define CXM_REG_I2C_SETSDA 0x2007004 + #define CXM_REG_IRQ_MASK 0x2000048 + #define CXM_REG_IRQ_STATUS 0x2000040 + #define CXM_REG_SPU 0x2009050 + #define CXM_REG_VDM 0x2002800 + #define CXM_REG_VPU 0x2009058 + + /* + * Register values + */ + #define CXM_CMD_AO_STOP 0x00000005 + #define CXM_CMD_APU_PING 0x00000000 + #define CXM_CMD_HW_BLOCKS_RST 0xffffffff + #define CXM_CMD_SDRAM_PRECHARGE_INIT 0x0000001a + #define CXM_CMD_SDRAM_REFRESH_INIT 0x80000640 + #define CXM_CMD_SPU_STOP 0x00000001 + #define CXM_CMD_VDM_STOP 0x00000000 + #define CXM_CMD_VPU_STOP15 0xfffffffe + #define CXM_CMD_VPU_STOP16 0xffffffee + + #define CXM_DMA_ERROR_LIST 0x00000008 + #define CXM_DMA_ERROR_READ 0x00000002 + #define CXM_DMA_ERROR_WRITE 0x00000004 + #define CXM_DMA_SUCCESS 0x00000001 + + #define CXM_IRQ_DEC_DMA_DONE (1 << 20) + #define CXM_IRQ_DEC_DMA_REQUEST (1 << 22) + #define CXM_IRQ_DEC_VSYNC (1 << 10) + #define CXM_IRQ_ENC_DMA_DONE (1 << 27) + #define CXM_IRQ_ENC_DMA_REQUEST (1 << 31) + #define CXM_IRQ_ENC_EOS (1 << 30) + #define CXM_IRQ_ENC_EVENT (1 << 28) + + #define CXM_IRQ_ENC (CXM_IRQ_ENC_DMA_REQUEST | CXM_IRQ_ENC_DMA_DONE \ + | CXM_IRQ_ENC_EOS | CXM_IRQ_ENC_EVENT) + + /* + * Register masks + */ + #define CXM_MASK_SPU_ENABLE 0xfffffffe + #define CXM_MASK_VPU_ENABLE15 0xfffffff6 + #define CXM_MASK_VPU_ENABLE16 0xfffffffb + + /* + * Firmware commands + */ + #define CXM_FW_CMD_ASSIGN_3_2_PULLDOWN 0x000000b1 + #define CXM_FW_CMD_ASSIGN_ASPECT_RATIO 0x00000099 + #define CXM_FW_CMD_ASSIGN_AUDIO_PROPERTIES 0x000000bd + #define CXM_FW_CMD_ASSIGN_BITRATES 0x00000095 + #define CXM_FW_CMD_ASSIGN_CORING_LEVELS 0x0000009f + #define CXM_FW_CMD_ASSIGN_DMA_BLOCKLEN 0x000000c9 + #define CXM_FW_CMD_ASSIGN_DNR_FILTER_MODE 0x0000009b + #define CXM_FW_CMD_ASSIGN_DNR_FILTER_PROPERTIES 0x0000009d + #define CXM_FW_CMD_ASSIGN_FRAME_DROP_RATE 0x000000d0 + #define CXM_FW_CMD_ASSIGN_FRAME_RATE 0x0000008f + #define CXM_FW_CMD_ASSIGN_FRAME_SIZE 0x00000091 + #define CXM_FW_CMD_ASSIGN_GOP_CLOSURE 0x000000c5 + #define CXM_FW_CMD_ASSIGN_GOP_PROPERTIES 0x00000097 + #define CXM_FW_CMD_ASSIGN_NUM_VSYNC_LINES 0x000000d6 + #define CXM_FW_CMD_ASSIGN_OUTPUT_PORT 0x000000bb + #define CXM_FW_CMD_ASSIGN_PGM_INDEX_INFO 0x000000c7 + #define CXM_FW_CMD_ASSIGN_PLACEHOLDER 0x000000d8 + #define CXM_FW_CMD_ASSIGN_SPATIAL_FILTER_TYPE 0x000000a1 + #define CXM_FW_CMD_ASSIGN_STREAM_TYPE 0x000000b9 + #define CXM_FW_CMD_ASSIGN_VBI_LINE 0x000000b7 + #define CXM_FW_CMD_ASSIGN_VBI_PROPERTIES 0x000000c8 + #define CXM_FW_CMD_BEGIN_CAPTURE 0x00000081 + #define CXM_FW_CMD_DEC_EVENT_NOTIFICATION 0x00000017 + #define CXM_FW_CMD_DEC_GET_FW_VER 0x00000011 + #define CXM_FW_CMD_DEC_HALT_FW 0x0000000e + #define CXM_FW_CMD_ENC_EVENT_NOTIFICATION 0x000000d5 + #define CXM_FW_CMD_ENC_GET_FW_VER 0x000000c4 + #define CXM_FW_CMD_ENC_HALT_FW 0x000000c3 + #define CXM_FW_CMD_END_CAPTURE 0x00000082 + #define CXM_FW_CMD_INITIALIZE_VIDEO_INPUT 0x000000cd + #define CXM_FW_CMD_PAUSE_ENCODER 0x000000d2 + #define CXM_FW_CMD_SCHED_DMA_TO_HOST 0x000000cc + + #define CXM_FW_STD_TIMEOUT 0x00010000 + + #define CXM_FW_CAPTURE_STREAM_TYPE_MPEG 0x00000000 + #define CXM_FW_CAPTURE_STREAM_TYPE_RAW 0x00000001 + #define CXM_FW_CAPTURE_STREAM_TYPE_RAW_PASSTHROUGH 0x00000002 + #define CXM_FW_CAPTURE_STREAM_TYPE_VBI 0x00000003 + + #define CXM_FW_CAPTURE_STREAM_YUV 0x00000001 + #define CXM_FW_CAPTURE_STREAM_PCM_AUDIO 0x00000002 + #define CXM_FW_CAPTURE_STREAM_VBI 0x00000004 + + #define CXM_FW_STREAM_TYPE_DVD 0x0000000a + #define CXM_FW_STREAM_TYPE_MPEG1 0x00000002 + #define CXM_FW_STREAM_TYPE_MPEG2_PROGRAM 0x00000000 + #define CXM_FW_STREAM_TYPE_VCD 0x0000000b + + /* + * I2C addresses + */ + #define CXM_I2C_EEPROM 0xa0 + #define CXM_I2C_IR 0x30 + #define CXM_I2C_MSP3400 0x80 + #define CXM_I2C_SAA7115 0x42 + #define CXM_I2C_TUNER 0xc2 + + /* The maximum wait time of the MSP + is 1 ms during normal operations. */ + #define CXM_I2C_TIMEOUT 1000 + + /* + * EEPROM + */ + int cxm_eeprom_init( struct cxm_softc *sc ); + int cxm_eeprom_tuner_type( struct cxm_softc *sc ); + + /* + * Infrared remote + */ + int cxm_ir_init( struct cxm_softc *sc ); + int cxm_ir_key( struct cxm_softc *sc, char *buf, int len ); + + /* + * Audio decoder + */ + #define CXM_MSP3400C_DEM 0x10 + #define CXM_MSP3400C_DFP 0x12 + + struct cxm_msp_setting { + unsigned char dev; + unsigned int addr; + char value[2]; + }; + + struct cxm_msp_command { + unsigned int nsettings; + struct cxm_msp_setting settings[4]; + }; + + int cxm_msp_init( struct cxm_softc *sc ); + int cxm_msp_mute( struct cxm_softc *sc ); + int cxm_msp_unmute( struct cxm_softc *sc ); + int cxm_msp_select_source( struct cxm_softc *sc, enum cxm_source source ); + int cxm_msp_autodetect_standard( struct cxm_softc *sc ); + int cxm_msp_is_locked( struct cxm_softc *sc ); + int cxm_msp_wait_for_lock( struct cxm_softc *sc ); + + /* + * Tuner + */ + #define CXM_TUNER_PHILIPS_FI1236_MK2 0 + #define CXM_TUNER_PHILIPS_FM1236 1 + #define CXM_TUNER_PHILIPS_FI1216_MK2 2 + #define CXM_TUNER_PHILIPS_FM1216 3 + #define CXM_TUNER_PHILIPS_FI1246_MK2 4 + #define CXM_TUNER_PHILIPS_FM1246 5 + + #define CXM_TUNER_TYPES 6 + + #define CXM_TUNER_AFC_MASK 0x07 + + #define CXM_TUNER_AFC_FREQ_MINUS_125 0x00 + #define CXM_TUNER_AFC_FREQ_MINUS_62 0x01 + #define CXM_TUNER_AFC_FREQ_CENTERED 0x02 + #define CXM_TUNER_AFC_FREQ_PLUS_62 0x03 + #define CXM_TUNER_AFC_FREQ_PLUS_125 0x04 + + #define CXM_TUNER_PHASE_LOCKED 0x40 + + struct cxm_tuner_band_code { + unsigned long freq; + unsigned char codes[2]; + }; + + struct cxm_tuner_channel_assignment { + unsigned int channel; + unsigned long freq; + unsigned long step; + }; + + struct cxm_tuner_channels { + const char *name; + unsigned int min_channel; + unsigned int max_channel; + unsigned long if_freq; + struct cxm_tuner_channel_assignment assignments[17]; + }; + + struct cxm_tuner { + const char *name; + unsigned long min_freq; + unsigned long max_freq; + struct cxm_tuner_band_code band_codes[3]; + unsigned long fm_min_freq; + unsigned long fm_max_freq; + struct cxm_tuner_band_code fm_band_code; + struct { + const struct cxm_tuner_channels *air; + const struct cxm_tuner_channels *cable; + } channels; + }; + + enum cxm_tuner_freq_type { cxm_tuner_unknown_freq_type, cxm_tuner_fm_freq_type, + cxm_tuner_tv_freq_type }; + + int cxm_tuner_init( struct cxm_softc *sc ); + int cxm_tuner_select_frequency( struct cxm_softc *sc, + enum cxm_tuner_freq_type type, + unsigned long freq ); + int cxm_tuner_select_channel( struct cxm_softc *sc, unsigned int channel ); + int cxm_tuner_apply_afc( struct cxm_softc *sc ); + int cxm_tuner_is_locked( struct cxm_softc *sc ); + int cxm_tuner_wait_for_lock( struct cxm_softc *sc ); + int cxm_tuner_status( struct cxm_softc *sc ); + + /* + * Video decoder + */ + struct cxm_saa7115_setting { + unsigned char addr; + unsigned int nvalues; + char values[32]; + }; + + struct cxm_saa7115_command { + unsigned int nsettings; + struct cxm_saa7115_setting settings[20]; + }; + + struct cxm_saa7115_scaling { + unsigned int width; + unsigned int height; + const struct cxm_saa7115_command *scaling; + }; + + int cxm_saa7115_init( struct cxm_softc *sc ); + int cxm_saa7115_mute( struct cxm_softc *sc ); + int cxm_saa7115_unmute( struct cxm_softc *sc ); + int cxm_saa7115_select_source( struct cxm_softc *sc, enum cxm_source source ); + int cxm_saa7115_configure_scaler( struct cxm_softc *sc, + unsigned int width, unsigned int height ); + enum cxm_source_format cxm_saa7115_detected_format( struct cxm_softc *sc ); + int cxm_saa7115_detected_fps( struct cxm_softc *sc ); + int cxm_saa7115_is_locked( struct cxm_softc *sc ); + int cxm_saa7115_wait_for_lock( struct cxm_softc *sc ); *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm_audio.c Wed Nov 12 01:18:04 2003 *************** *** 0 **** --- 1,520 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Audio decoder routines for the Conexant MPEG-2 Codec driver. + * + * Ideally these routines should be implemented as a separate + * driver which has a generic audio decoder interface so that + * it's not necessary for each multimedia driver to re-invent + * the wheel. + */ + + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + + #include + #include + + #include + + #include + #include + + #include "iicbb_if.h" + + + static const struct cxm_msp_command + msp343xG_init = { + 4, + { + /* Enable Automatic Sound Select */ + { CXM_MSP3400C_DEM, 0x0030, { 0x20, 0x03 } }, + /* SCART prescale = 0 dB */ + { CXM_MSP3400C_DFP, 0x000d, { 0x19, 0x00 } }, + /* FM / AM Prescale = 100 Khz and FM Matrix = Sound A Mono */ + { CXM_MSP3400C_DFP, 0x000e, { 0x24, 0x03 } }, + /* Enable Automatic Standard Select */ + { CXM_MSP3400C_DEM, 0x0020, { 0x00, 0x01 } }, + } + }; + + static const struct cxm_msp_command + msp34xxx_mute = { + 2, + { + /* Loudspeaker volume = mute */ + { CXM_MSP3400C_DFP, 0x0000, { 0x00, 0x00 } }, + /* SC1_OUT_L/R volume = mute */ + { CXM_MSP3400C_DFP, 0x0007, { 0x00, 0x01 } } + } + }; + + static const struct cxm_msp_command + msp34xxx_unmute = { + 2, + { + /* Loudspeaker volume = 0 db */ + { CXM_MSP3400C_DFP, 0x0000, { 0x73, 0x00 } }, + /* SC1_OUT_L/R volume = 0 db */ + { CXM_MSP3400C_DFP, 0x0007, { 0x73, 0x01 } } + } + }; + + static const struct cxm_msp_command + msp34xxx_select_fm = { + 3, + { + /* Loudspeaker Source = SCART, Matrix = STEREO */ + { CXM_MSP3400C_DFP, 0x0008, { 0x02, 0x20 } }, + /* SCART1_L/R Source = SCART, Matrix = STEREO */ + { CXM_MSP3400C_DFP, 0x000a, { 0x02, 0x20 } }, + /* DSP In = SC2_IN_L/R, SC1_OUT_L/R Source = SCART1_L/R */ + { CXM_MSP3400C_DFP, 0x0013, { 0x0e, 0x00 } } + } + }; + + static const struct cxm_msp_command + msp34xxx_select_line_in = { + 3, + { + /* Loudspeaker Source = SCART, Matrix = STEREO */ + { CXM_MSP3400C_DFP, 0x0008, { 0x02, 0x20 } }, + /* SCART1_L/R Source = SCART, Matrix = STEREO */ + { CXM_MSP3400C_DFP, 0x000a, { 0x02, 0x20 } }, + /* DSP In = SC1_IN_L/R, SC1_OUT_L/R Source = SCART1_L/R */ + { CXM_MSP3400C_DFP, 0x0013, { 0x0c, 0x00 } } + } + }; + + static const struct cxm_msp_command + msp34xxx_select_tuner = { + 3, + { + /* Loudspeaker Source = demodulator (St or A), Matrix = St */ + { CXM_MSP3400C_DFP, 0x0008, { 0x03, 0x20 } }, + /* SCART1_L/R Source = demodulator (St or A), Matrix = St */ + { CXM_MSP3400C_DFP, 0x000a, { 0x03, 0x20 } }, + /* DSP In = mute, SC1_OUT_L/R Source = SCART1_L/R */ + { CXM_MSP3400C_DFP, 0x0013, { 0x0f, 0x20 } } + } + }; + + + /* Reset the MSP or DPL chip */ + static int + cxm_msp_dpl_reset( device_t iicbus, int i2c_addr ) + { + unsigned char msg[3]; + int sent; + + /* put into reset mode */ + msg[0] = 0x00; + msg[1] = 0x80; + msg[2] = 0x00; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + iicbus_stop(iicbus); + + /* put back to operational mode */ + msg[0] = 0x00; + msg[1] = 0x00; + msg[2] = 0x00; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + iicbus_stop(iicbus); + + return 0; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + /* Read from the MSP or DPL registers */ + static int + cxm_msp_dpl_read( device_t iicbus, int i2c_addr, + unsigned char dev, unsigned int addr, + char *buf, int len ) + { + unsigned char msg[3]; + int received; + int sent; + + msg[0] = (unsigned char)(dev + 1); + msg[1] = (unsigned char)(addr >> 8); + msg[2] = (unsigned char)addr; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + if (iicbus_repeated_start(iicbus, i2c_addr + 1, CXM_I2C_TIMEOUT) != 0) + goto fail; + + if (iicbus_read(iicbus, buf, len, &received, IIC_LAST_READ, 0) != 0) + goto fail; + + iicbus_stop(iicbus); + + return received; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + /* Write to the MSP or DPL registers */ + static int + cxm_msp_dpl_write( device_t iicbus, int i2c_addr, + unsigned char dev, unsigned int addr, + const char *buf, int len ) + { + unsigned char msg[3]; + int sent; + + msg[0] = (unsigned char)dev; + msg[1] = (unsigned char)(addr >> 8); + msg[2] = (unsigned char)addr; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + if (iicbus_write(iicbus, buf, len, &sent, CXM_I2C_TIMEOUT) != 0) + goto fail; + + iicbus_stop(iicbus); + + return sent; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + int + cxm_msp_init( struct cxm_softc *sc ) + { + unsigned char rev1[2]; + unsigned char rev2[2]; + unsigned int i; + unsigned int nsettings; + const struct cxm_msp_setting *settings; + + if (cxm_msp_dpl_reset (sc->iicbus, CXM_I2C_MSP3400) < 0) + return -1; + + if (cxm_msp_dpl_read(sc->iicbus, CXM_I2C_MSP3400, CXM_MSP3400C_DFP, + 0x001e, rev1, sizeof(rev1)) != sizeof(rev1)) + return -1; + + if (cxm_msp_dpl_read(sc->iicbus, CXM_I2C_MSP3400, CXM_MSP3400C_DFP, + 0x001f, rev2, sizeof(rev2)) != sizeof(rev2)) + return -1; + + snprintf(sc->msp_name, sizeof(sc->msp_name), "34%02d%c-%c%d", + rev2[0], rev1[1] + '@', rev1[0] + '@', rev2[1] & 0x1f); + + if (sc->msp_name[2] != '3' || sc->msp_name[4] != 'G') { + printf("%s: unknown audio decoder MSP%s\n", + sc->name, sc->msp_name); + return -1; + } + + nsettings = msp343xG_init.nsettings; + settings = msp343xG_init.settings; + + for (i = 0; i < nsettings; i++) + if (cxm_msp_dpl_write(sc->iicbus, CXM_I2C_MSP3400, + settings[i].dev, settings[i].addr, + settings[i].value, + sizeof(settings[i].value)) + != sizeof(settings[i].value)) + return -1; + + if (cxm_msp_select_source(sc, cxm_tuner_source) < 0) + return -1; + + printf("%s: MSP%s audio decoder\n", sc->name, sc->msp_name); + + return 0; + } + + + int + cxm_msp_mute( struct cxm_softc *sc ) + { + unsigned int i; + unsigned int nsettings; + const struct cxm_msp_setting *settings; + + nsettings = msp34xxx_mute.nsettings; + settings = msp34xxx_mute.settings; + + for (i = 0; i < nsettings; i++) + if (cxm_msp_dpl_write(sc->iicbus, CXM_I2C_MSP3400, + settings[i].dev, settings[i].addr, + settings[i].value, + sizeof(settings[i].value)) + != sizeof(settings[i].value)) + return -1; + + return 0; + } + + + int + cxm_msp_unmute( struct cxm_softc *sc ) + { + unsigned int i; + unsigned int nsettings; + const struct cxm_msp_setting *settings; + + nsettings = msp34xxx_unmute.nsettings; + settings = msp34xxx_unmute.settings; + + for (i = 0; i < nsettings; i++) + if (cxm_msp_dpl_write(sc->iicbus, CXM_I2C_MSP3400, + settings[i].dev, settings[i].addr, + settings[i].value, + sizeof(settings[i].value)) + != sizeof(settings[i].value)) + return -1; + + return 0; + } + + + int + cxm_msp_select_source( struct cxm_softc *sc, enum cxm_source source ) + { + unsigned int i; + unsigned int nsettings; + const struct cxm_msp_setting *settings; + + switch (source) { + case cxm_fm_source: + nsettings = msp34xxx_select_fm.nsettings; + settings = msp34xxx_select_fm.settings; + break; + + case cxm_line_in_source_composite: + case cxm_line_in_source_svideo: + nsettings = msp34xxx_select_line_in.nsettings; + settings = msp34xxx_select_line_in.settings; + break; + + case cxm_tuner_source: + nsettings = msp34xxx_select_tuner.nsettings; + settings = msp34xxx_select_tuner.settings; + break; + + default: + return -1; + } + + for (i = 0; i < nsettings; i++) + if (cxm_msp_dpl_write(sc->iicbus, CXM_I2C_MSP3400, + settings[i].dev, settings[i].addr, + settings[i].value, + sizeof(settings[i].value)) + != sizeof(settings[i].value)) + return -1; + + return 0; + } + + + int + cxm_msp_autodetect_standard( struct cxm_softc *sc ) + { + unsigned char source[2]; + unsigned int i; + unsigned int nsettings; + const struct cxm_msp_setting *settings; + + if (cxm_msp_dpl_read(sc->iicbus, CXM_I2C_MSP3400, CXM_MSP3400C_DFP, + 0x0008, source, sizeof(source)) != sizeof(source)) + return -1; + + switch (source[0]) { + case 0: /* FM / AM mono signal */ + case 1: /* Stereo or A / B */ + case 3: /* Stereo or A */ + case 4: /* Stereo or B */ + break; + + default: + return 0; + } + + /* + * Section 3.3.2.2 of the data sheet states: + * + * A general refresh of the STANDARD SELECT + * register is not allowed. + */ + + if (cxm_msp_dpl_reset (sc->iicbus, CXM_I2C_MSP3400) < 0) + return -1; + + nsettings = msp343xG_init.nsettings; + settings = msp343xG_init.settings; + + for (i = 0; i < nsettings; i++) + if (cxm_msp_dpl_write(sc->iicbus, CXM_I2C_MSP3400, + settings[i].dev, settings[i].addr, + settings[i].value, + sizeof(settings[i].value)) + != sizeof(settings[i].value)) + return -1; + + if (cxm_msp_select_source(sc, cxm_tuner_source) < 0) + return -1; + + return 0; + } + + + int + cxm_msp_is_locked( struct cxm_softc *sc ) + { + unsigned char source[2]; + unsigned char standard[2]; + unsigned char status[2]; + + if (cxm_msp_dpl_read(sc->iicbus, CXM_I2C_MSP3400, CXM_MSP3400C_DFP, + 0x0008, source, sizeof(source)) != sizeof(source)) + return -1; + + switch (source[0]) { + case 0: /* FM / AM mono signal */ + case 1: /* Stereo or A / B */ + case 3: /* Stereo or A */ + case 4: /* Stereo or B */ + break; + + default: + return 1; + } + + if (cxm_msp_dpl_read(sc->iicbus, CXM_I2C_MSP3400, CXM_MSP3400C_DEM, + 0x007e, standard, sizeof(standard)) + != sizeof(standard)) + return -1; + + if (standard[0] >= 8 || (standard[0] == 0 && standard[1] == 0)) + return 0; + + if (cxm_msp_dpl_read(sc->iicbus, CXM_I2C_MSP3400, CXM_MSP3400C_DEM, + 0x0200, status, sizeof(status)) != sizeof(status)) + return -1; + + return (status[1] & 0x06) == 0x06 ? 0 : 1; + } + + + int + cxm_msp_wait_for_lock( struct cxm_softc *sc ) + { + unsigned int i; + + /* + * Section 3.3.2.1 of the data sheet states: + * + * Within 0.5 s the detection and setup of the actual + * TV sound standard is performed. The detected result + * can be read out of the STANDARD RESULT register by + * the control processor. + */ + + for (i = 0; i < 10; i++) { + + /* + * The input may have just change (prior to + * cxm_msp_wait_for_lock) so start with the + * delay to give the audio decoder a chance + * to update it's status. + */ + + tsleep(&sc->iicbus, PZERO, "audio", hz / 20 ); + + switch (cxm_msp_is_locked(sc)) { + case 1: + return 1; + + case 0: + break; + + default: + return -1; + } + } + + printf("%s: audio decoder failed to lock\n", sc->name); + + return -1; + } *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm_eeprom.c Sat Nov 15 19:56:43 2003 *************** *** 0 **** --- 1,190 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * EEPROM routines for the Conexant MPEG-2 Codec driver. + * + * Ideally these routines should be implemented as a separate + * driver which has a generic EEPROM interface so that it's + * not necessary for each multimedia driver to re-invent the + * wheel. + */ + + + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + + #include + #include + + #include + + #include + #include + + #include "iicbb_if.h" + + + static int + cxm_eeprom_read( device_t iicbus, int i2c_addr, + char *buf, int len, unsigned int offset ) + { + char msg[1]; + int received; + int sent; + + msg[0] = (unsigned char)offset; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + if (iicbus_repeated_start(iicbus, i2c_addr + 1, CXM_I2C_TIMEOUT) != 0) + goto fail; + + if (iicbus_read(iicbus, buf, len, &received, IIC_LAST_READ, 0) != 0) + goto fail; + + iicbus_stop(iicbus); + + return received; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + int + cxm_eeprom_init( struct cxm_softc *sc ) + { + unsigned char eeprom[1]; + + if (cxm_eeprom_read(sc->iicbus, CXM_I2C_EEPROM, + eeprom, sizeof(eeprom), 0) != sizeof(eeprom)) + return -1; + + return 0; + } + + + int + cxm_eeprom_tuner_type( struct cxm_softc *sc ) + { + unsigned char eeprom[256]; + unsigned int subsystem_vendor_id; + unsigned int tuner_code; + int tuner_type; + + if (cxm_eeprom_read(sc->iicbus, CXM_I2C_EEPROM, + eeprom, sizeof(eeprom), 0) != sizeof(eeprom)) + return -1; + + subsystem_vendor_id = (unsigned int)eeprom[254] << 8 | eeprom[255]; + tuner_type = -1; + + switch (subsystem_vendor_id) { + case CXM_VENDORID_HAUPPAUGE: + if (eeprom[0] != 0x84) { + printf("%s: unknown Hauppauge eeprom format %#x\n", + sc->name, (unsigned int)eeprom[0]); + break; + } + + tuner_code = eeprom[9]; + + switch (tuner_code) { + case 0x03: /* Philips FI1216 */ + case 0x08: /* Philips FI1216 MK2 */ + case 0x1d: /* Temic 4006FH5 */ + tuner_type = CXM_TUNER_PHILIPS_FI1216_MK2; + break; + + case 0x05: /* Philips FI1236 */ + case 0x0a: /* Philips FI1236 MK2 */ + case 0x1a: /* Temic 4036FY5 */ + tuner_type = CXM_TUNER_PHILIPS_FI1236_MK2; + break; + + case 0x06: /* Philips FI1246 */ + case 0x0b: /* Philips FI1246 MK2 */ + case 0x23: /* Temic 4066FY5 */ + tuner_type = CXM_TUNER_PHILIPS_FI1246_MK2; + break; + + case 0x10: /* Philips FR1216 MK2 */ + case 0x15: /* Philips FM1216 */ + case 0x2a: /* Temic 4009FR5 */ + tuner_type = CXM_TUNER_PHILIPS_FM1216; + break; + + case 0x12: /* Philips FR1236 MK2 */ + case 0x17: /* Philips FM1236 */ + case 0x21: /* Temic 4039FY5 */ + tuner_type = CXM_TUNER_PHILIPS_FM1236; + break; + + case 0x13: /* Philips FR1246 MK2 */ + case 0x18: /* Philips FM1246 */ + tuner_type = CXM_TUNER_PHILIPS_FM1246; + break; + + default: + printf("%s: unknown tuner code %#x\n", + sc->name, tuner_code); + break; + } + break; + + default: + printf("%s: unknown subsystem vendor id %#x\n", + sc->name, subsystem_vendor_id); + break; + } + + return tuner_type; + } *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm_i2c.c Sat Nov 15 21:44:09 2003 *************** *** 0 **** --- 1,281 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * I2c routines for the Conexant MPEG-2 Codec driver. + */ + + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + + #include + #include + + #include + + #include + #include + + #include "iicbb_if.h" + + + static int cxm_iic_probe( device_t dev ); + static int cxm_iic_attach( device_t dev ); + static int cxm_iic_detach( device_t dev ); + + static int cxm_iic_callback( device_t, int, caddr_t * ); + static void cxm_iic_setlines( device_t, int, int ); + static int cxm_iic_getdataline( device_t ); + static int cxm_iic_reset( device_t, u_char, u_char, u_char * ); + + static device_method_t cxm_iic_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, cxm_iic_probe), + DEVMETHOD(device_attach, cxm_iic_attach), + DEVMETHOD(device_detach, cxm_iic_detach), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + /* iicbb interface */ + DEVMETHOD(iicbb_callback, cxm_iic_callback), + DEVMETHOD(iicbb_setlines, cxm_iic_setlines), + DEVMETHOD(iicbb_getdataline, cxm_iic_getdataline), + DEVMETHOD(iicbb_reset, cxm_iic_reset), + + { 0, 0 } + }; + + static driver_t cxm_iic_driver = { + "cxm_iic", + cxm_iic_methods, + sizeof(struct cxm_iic_softc), + }; + + static devclass_t cxm_iic_devclass; + + MODULE_VERSION(cxm_iic, 1); + DRIVER_MODULE(cxm_iic, cxm, cxm_iic_driver, cxm_iic_devclass, 0, 0); + + + /* + * the boot time probe routine. + * + * The cxm_iic device is only probed after it has + * been established that the cxm device is present + * which means that the cxm_iic device * must * + * be present since it's built into the cxm hardware. + */ + static int + cxm_iic_probe( device_t dev ) + { + device_set_desc(dev, "Conexant iTVC15 / iTVC16 I2C controller"); + + return 0; + } + + + /* + * the attach routine. + */ + static int + cxm_iic_attach( device_t dev ) + { + device_t *kids; + device_t iicbus; + int error; + int numkids; + int i; + int unit; + unsigned int bhandle; + unsigned int btag; + struct cxm_iic_softc *sc; + + /* Get the device data */ + sc = device_get_softc(dev); + unit = device_get_unit(dev); + + /* build the device name */ + snprintf(sc->name, sizeof(sc->name), "cxm_iic%d",unit); + + /* retrieve the cxm btag and bhandle */ + if (BUS_READ_IVAR(device_get_parent(dev), dev, CXM_IVAR_BTAG, &btag) + || BUS_READ_IVAR(device_get_parent(dev), dev, + CXM_IVAR_BHANDLE, &bhandle)) { + device_printf(dev, + "could not retrieve bus space information\n"); + return ENXIO; + } + + sc->btag = btag; + sc->bhandle = bhandle; + + /* add bit-banging generic code onto cxm_iic interface */ + sc->iicbb = device_add_child(dev, "iicbb", -1); + + if (! sc->iicbb) { + device_printf(dev, "could not add iicbb\n"); + return ENXIO; + } + + /* probed and attached the bit-banging code */ + error = device_probe_and_attach(sc->iicbb); + + if (error) { + device_printf(dev, "could not attach iicbb\n"); + goto fail; + } + + /* locate iicbus which was attached by the bit-banging code */ + iicbus = NULL; + device_get_children(sc->iicbb, &kids, &numkids); + for (i = 0; i < numkids; i++) + if (strcmp(device_get_name(kids[i]), "iicbus") == 0) { + iicbus = kids[i]; + break; + } + free(kids, M_TEMP); + + if (! iicbus) { + device_printf(dev, "could not find iicbus\n"); + error = ENXIO; + goto fail; + } + + if (BUS_WRITE_IVAR(device_get_parent(dev), dev, + CXM_IVAR_IICBUS, (uintptr_t)iicbus)) { + device_printf(dev, "could not store iicbus information\n"); + error = ENXIO; + goto fail; + } + + return 0; + + fail: + bus_generic_detach(dev); + device_delete_child(dev, sc->iicbb); + return error; + } + + + /* + * the detach routine. + */ + static int + cxm_iic_detach( device_t dev ) + { + struct cxm_iic_softc *sc; + + /* Get the device data */ + sc = device_get_softc(dev); + + (void)BUS_WRITE_IVAR(device_get_parent(dev), dev, CXM_IVAR_IICBUS, 0); + + bus_generic_detach(dev); + device_delete_child(dev, sc->iicbb); + + return 0; + } + + + static int + cxm_iic_callback( device_t dev, int index, caddr_t *data ) + { + return 0; + } + + + static void + cxm_iic_setlines( device_t dev, int ctrl, int data ) + { + struct cxm_iic_softc *sc; + + /* Get the device data */ + sc = (struct cxm_iic_softc *)device_get_softc(dev); + + /* Set scl to the requested value */ + CSR_WRITE_4(sc, CXM_REG_I2C_SETSCL, ~(int)(ctrl ? 1 : 0)); + + /* Set sda to the requested value */ + CSR_WRITE_4(sc, CXM_REG_I2C_SETSDA, ~(int)(data ? 1 : 0)); + + /* Wait for 10 usec */ + DELAY(10); + } + + + static int + cxm_iic_getdataline( device_t dev ) + { + struct cxm_iic_softc *sc; + + /* Get the device data */ + sc = (struct cxm_iic_softc *)device_get_softc(dev); + + /* Get sda */ + return CSR_READ_1(sc, CXM_REG_I2C_GETSDA); + } + + + static int + cxm_iic_reset( device_t dev, u_char speed, u_char addr, u_char * oldaddr ) + { + struct cxm_iic_softc *sc; + + /* Get the device data */ + sc = (struct cxm_iic_softc *)device_get_softc(dev); + + /* Set scl to 1 */ + CSR_WRITE_4(sc, CXM_REG_I2C_SETSCL, ~(int)1); + + /* Set sda to 1 */ + CSR_WRITE_4(sc, CXM_REG_I2C_SETSDA, ~(int)1); + + /* Wait for 10 usec */ + DELAY(10); + + return IIC_ENOADDR; + } *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm_tuner.c Sat Nov 15 19:41:23 2003 *************** *** 0 **** --- 1,524 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Tuner routines for the Conexant MPEG-2 Codec driver. + * + * Ideally these routines should be implemented as a separate + * driver which has a generic tuner interface so that it's + * not necessary for each multimedia driver to re-invent the + * wheel. + */ + + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + + #include + #include + + #include + + #include + #include + + #include "iicbb_if.h" + + + /* + * Channel mappings derived from + * http://developer.apple.com/technotes/tn/tn1012.html + */ + + static const struct cxm_tuner_channels + us_air_channels = { + "US Broadcast", + 2, + 69, + 45750, + { { 14, 471250, 6000 }, + { 7, 175250, 6000 }, + { 5, 77250, 6000 }, + { 2, 55250, 6000 } } + }; + + static const struct cxm_tuner_channels + us_cable_channels = { + "US Cable", + 2, + 125, + 45750, + { { 100, 649250, 6000 }, + { 95, 91250, 6000 }, + { 23, 217250, 6000 }, + { 14, 121250, 6000 }, + { 7, 175250, 6000 }, + { 5, 77250, 6000 }, + { 2, 55250, 6000 } } + }; + + static const struct cxm_tuner_channels + bg_air_channels = { + "B/G Broadcast", + 2, + 89, + 38900, + { { 82, 175250, 7000 }, + { 80, 55250, 7000 }, + { 79, 217250, 7000 }, + { 77, 209250, 7000 }, + { 76, 138250, 9000 }, + { 75, 102250, 9000 }, + { 73, 86250, 9000 }, + { 72, 64250, 7500 }, + { 70, 49750, 7500 }, + { 21, 471250, 8000 }, + { 20, 210250, 8500 }, + { 18, 192750, 8500 }, + { 16, 175250, 8000 }, + { 15, 82250, 8500 }, + { 13, 53750, 8500 }, + { 5, 175250, 7000 }, + { 2, 48250, 7000 } } + }; + + static const struct cxm_tuner_channels + i_air_channels = { + "I Broadcast", + 1, + 83, + 38900, + { { 75, 179750, 5000 }, + { 71, 51750, 5000 }, + { 70, 45000, 5000 }, + { 21, 471250, 8000 }, + { 20, 0, 0 }, + { 19, 0, 0 }, + { 18, 0, 0 }, + { 17, 0, 0 }, + { 16, 0, 0 }, + { 15, 0, 0 }, + { 14, 0, 0 }, + { 13, 247250, 8000 }, + { 12, 0, 0 }, + { 4, 175250, 8000 }, + { 1, 45750, 8000 } } + }; + + + const struct cxm_tuner + cxm_tuners[CXM_TUNER_TYPES] = { + { "Philips FI1236 MK2", 55250, 801250, + { { 454000, { 0x8e, 0x30 } }, + { 160000, { 0x8e, 0x90 } }, + { 55250, { 0x8e, 0xa0 } } }, + 0, 0, + { 0, { 0x00, 0x00 } }, + { &us_air_channels, &us_cable_channels } }, + { "Philips FM1236", 55250, 801250, + { { 454000, { 0xce, 0x30 } }, + { 160000, { 0xce, 0x90 } }, + { 55250, { 0xce, 0xa0 } } }, + 76000, 108000, + { 76000, { 0x88, 0xa5 } }, + { &us_air_channels, &us_cable_channels } }, + { "Philips FI1216 MK2", 48250, 855250, + { { 450000, { 0x8e, 0x30 } }, + { 170000, { 0x8e, 0x90 } }, + { 48250, { 0x8e, 0xa0 } } }, + 0, 0, + { 0, { 0x00, 0x00 } }, + { &bg_air_channels, NULL } }, + { "Philips FM1216", 48250, 855250, + { { 450000, { 0xce, 0x30 } }, + { 170000, { 0xce, 0x90 } }, + { 48250, { 0xce, 0xa0 } } }, + 87500, 108000, + { 87500, { 0x88, 0xa5 } }, + { &bg_air_channels, NULL } }, + { "Philips FI1246 MK2", 45750, 855250, + { { 450000, { 0x8e, 0x30 } }, + { 170000, { 0x8e, 0x90 } }, + { 45750, { 0x8e, 0xa0 } } }, + 0, 0, + { 0, { 0x00, 0x00 } }, + { &i_air_channels, NULL } }, + { "Philips FM1246", 45750, 855250, + { { 450000, { 0xce, 0x30 } }, + { 170000, { 0xce, 0x90 } }, + { 45750, { 0xce, 0xa0 } } }, + 87500, 108000, + { 87500, { 0x88, 0xa5 } }, + { &i_air_channels, NULL } } + }; + + + /* Read from the tuner registers */ + static int + cxm_tuner_read( device_t iicbus, int i2c_addr, char *buf, int len ) + { + int received; + + if (iicbus_start(iicbus, i2c_addr + 1, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_read(iicbus, buf, len, &received, IIC_LAST_READ, 0) != 0) + goto fail; + + iicbus_stop(iicbus); + + return received; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + /* Write to the tuner registers */ + static int + cxm_tuner_write( device_t iicbus, int i2c_addr, const char *buf, int len ) + { + int sent; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, buf, len, &sent, CXM_I2C_TIMEOUT) != 0) + goto fail; + + iicbus_stop(iicbus); + + return sent; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + int + cxm_tuner_init( struct cxm_softc *sc ) + { + unsigned char status; + int tuner_type; + + if (cxm_eeprom_init(sc) < 0) + return -1; + + tuner_type = cxm_eeprom_tuner_type(sc); + + if (tuner_type < 0 || tuner_type >= NUM_ELEMENTS(cxm_tuners)) + return -1; + + sc->tuner = &cxm_tuners[tuner_type]; + sc->tuner_channels = sc->tuner->channels.cable + ? sc->tuner->channels.cable + : sc->tuner->channels.air; + sc->tuner_freq = 0; + + if (cxm_tuner_read(sc->iicbus, CXM_I2C_TUNER, &status, sizeof(status)) + != sizeof(status)) + return -1; + + if (cxm_tuner_select_channel(sc, 4) < 0) + return -1; + + printf("%s: %s tuner\n", sc->name, sc->tuner->name); + + return 0; + } + + + int + cxm_tuner_select_frequency( struct cxm_softc *sc, + enum cxm_tuner_freq_type freq_type, + unsigned long freq ) + { + unsigned char msg[4]; + unsigned long N; + unsigned long osc_freq; + const struct cxm_tuner_band_code *band_codes; + + N = 0; + + switch (freq_type) { + case cxm_tuner_fm_freq_type: + + if (freq < sc->tuner->fm_min_freq + || freq > sc->tuner->fm_max_freq + || ! sc->tuner->fm_band_code.freq) + return -1; + + /* + * N = { fRF(pc) + fIF(pc) } / step_size + * + * fRF = RF frequency in MHz + * fIF = Intermediate frequency in MHz (FM = 10.70 MHz) + * step_size = Step size in MHz (FM = 50 kHz) + */ + + osc_freq = freq + 10700; + + N = (20 * osc_freq) / 1000; + + msg[0] = (unsigned char)(N >> 8); + msg[1] = (unsigned char)N; + msg[2] = sc->tuner->fm_band_code.codes[0]; + msg[3] = sc->tuner->fm_band_code.codes[1]; + break; + + case cxm_tuner_tv_freq_type: + + if (freq < sc->tuner->min_freq + || freq > sc->tuner->max_freq) + return -1; + + /* + * N = 16 * { fRF(pc) + fIF(pc) } + * + * fRF = RF frequency in MHz + * fIF = Intermediate frequency in MHz + * + * The data sheet doesn't state it, however + * this is probably the same equation as + * FM simply with 62.5 kHz as the step size. + */ + + osc_freq = freq + sc->tuner_channels->if_freq; + + N = (16 * osc_freq) / 1000; + + for (band_codes = sc->tuner->band_codes; + band_codes->freq > freq; band_codes++) + ; + + if (freq >= sc->tuner_freq) { + msg[0] = (unsigned char)(N >> 8); + msg[1] = (unsigned char)N; + msg[2] = band_codes->codes[0]; + msg[3] = band_codes->codes[1]; + } + else { + msg[0] = band_codes->codes[0]; + msg[1] = band_codes->codes[1]; + msg[2] = (unsigned char)(N >> 8); + msg[3] = (unsigned char)N; + } + break; + + default: + return -1; + } + + if (N > 32767) + return -1; + + if (cxm_tuner_write(sc->iicbus, CXM_I2C_TUNER, msg, sizeof(msg)) + != sizeof(msg)) + return -1; + + sc->tuner_freq = freq; + + return 0; + } + + + int + cxm_tuner_select_channel( struct cxm_softc *sc, unsigned int channel ) + { + unsigned long freq; + const struct cxm_tuner_channel_assignment *assignments; + const struct cxm_tuner_channels *channels; + + channels = sc->tuner_channels; + + if (! channels + || channel < channels->min_channel + || channel > channels->max_channel) + return -1; + + for (assignments = channels->assignments; + assignments->channel > channel; assignments++) + ; + + freq = assignments->freq + + (channel - assignments->channel) * assignments->step; + + return cxm_tuner_select_frequency(sc, cxm_tuner_tv_freq_type, freq); + } + + + int + cxm_tuner_apply_afc( struct cxm_softc *sc ) + { + unsigned char status; + unsigned int i; + unsigned long freq; + unsigned long max_offset; + unsigned long original_freq; + unsigned long prev_freq; + unsigned long step_size; + + if (cxm_tuner_wait_for_lock(sc) != 1) + return -1; + + original_freq = sc->tuner_freq; + + freq = sc->tuner_freq; + prev_freq = 0; + max_offset = 2000; + step_size = 63; + + for (i = 0; i < (max_offset / step_size); i++) { + if (cxm_tuner_read(sc->iicbus, CXM_I2C_TUNER, + &status, sizeof(status)) != sizeof(status)) + break; + + if (! (status & CXM_TUNER_PHASE_LOCKED) ) + break; + + switch (status & CXM_TUNER_AFC_MASK) { + case CXM_TUNER_AFC_FREQ_CENTERED: + return 0; + + case CXM_TUNER_AFC_FREQ_MINUS_125: + case CXM_TUNER_AFC_FREQ_MINUS_62: + freq -= step_size; + break; + + case CXM_TUNER_AFC_FREQ_PLUS_62: + case CXM_TUNER_AFC_FREQ_PLUS_125: + freq += step_size; + break; + + default: + goto fail; + } + + if (freq == prev_freq) + return 0; + prev_freq = sc->tuner_freq; + + if (cxm_tuner_select_frequency(sc, cxm_tuner_tv_freq_type, + freq) < 0) + break; + + /* + * Delay long enough for the tuner to update it's status. + */ + + tsleep(&sc->iicbus, PZERO, "afc", hz / 10 ); + } + + fail: + (void)cxm_tuner_select_frequency(sc, cxm_tuner_tv_freq_type, + original_freq); + return -1; + } + + + int + cxm_tuner_is_locked( struct cxm_softc *sc ) + { + unsigned char status; + + if (cxm_tuner_read(sc->iicbus, CXM_I2C_TUNER, &status, sizeof(status)) + != sizeof(status)) + return -1; + + return (status & CXM_TUNER_PHASE_LOCKED) ? 1 : 0; + } + + + int + cxm_tuner_wait_for_lock( struct cxm_softc *sc ) + { + unsigned int i; + + /* + * The data sheet states the maximum lock-in time + * is 150 ms using fast tuning ... unfortunately + * it doesn't state the maximum lock-in time using + * moderate tuning. Hopefully 300 ms is enough. + */ + + for (i = 0; i < 3; i++) { + + /* + * The frequency may have just change (prior to + * cxm_tuner_wait_for_lock) so start with the delay + * to give the tuner a chance to update it's status. + */ + + tsleep(&sc->iicbus, PZERO, "tuner", hz / 10); + + switch (cxm_tuner_is_locked(sc)) { + case 1: + return 1; + + case 0: + break; + + default: + return -1; + } + } + + printf("%s: tuner failed to lock\n", sc->name); + + return -1; + } + + + int + cxm_tuner_status( struct cxm_softc *sc ) + { + unsigned char status; + + if (cxm_tuner_read(sc->iicbus, CXM_I2C_TUNER, &status, sizeof(status)) + != sizeof(status)) + return -1; + + return status; + } *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm_video.c Sun Nov 23 00:52:48 2003 *************** *** 0 **** --- 1,922 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Video decoder routines for the Conexant MPEG-2 Codec driver. + * + * Ideally these routines should be implemented as a separate + * driver which has a generic video decoder interface so that + * it's not necessary for each multimedia driver to re-invent + * the wheel. + */ + + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + + #include + #include + + #include + + #include + #include + + #include "iicbb_if.h" + + + static const struct cxm_saa7115_command + saa7115_init = { + 12, + { + /* Full auto mode for CVBS */ + { 0x01, 1, { 0x08 } }, + { 0x03, 18, { 0x20, 0x90, 0x90, 0xeb, 0xe0, 0xb0, 0x40, 0x80, + 0x44, 0x40, 0x00, 0x07, 0x2a, 0x06, 0x00, 0x9d, + 0x80, 0x01 } }, + { 0x17, 7, { 0x99, 0x40, 0x80, 0x77, 0x42, 0xa9, 0x01 } }, + + /* VBI data slicer (raw VBI data on lines 10 through 20) */ + { 0x40, 20, { 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd } }, + { 0x56, 4, { 0x00, 0x00, 0x00, 0x47 } }, + { 0x5c, 3, { 0x00, 0x1f, 0x35 } }, + + /* I-port and X-port configuration */ + { 0x80, 2, { 0x00, 0x01 } }, + { 0x83, 5, { 0x00, 0x20, 0x21, 0xc5, 0x01 } }, + + /* Scaler input configuration and output format settings */ + { 0x90, 4, { 0x00, 0x08, 0x00, 0x80 } }, + + /* Audio Master Clock to Audio Serial Clock ratio */ + { 0x38, 3, { 0x03, 0x10, 0x00 } }, + + /* PLL2 target clock 27 MHz (using a 32.11 MHz crystal) */ + { 0xf1, 4, { 0x05, 0xd0, 0x35, 0x00 } }, + + /* Pulse generator */ + { 0xf6, 10, { 0x61, 0x0e, 0x60, 0x0e, 0x60, 0x0e, 0x00, + 0x00, 0x00, 0x88 } } + } + }; + + static const struct cxm_saa7115_command + saa7115_mute = { + 1, + { + /* Disable I-port */ + { 0x87, 1, { 0x00 } }, + } + }; + + static const struct cxm_saa7115_command + saa7115_unmute = { + 1, + { + /* Enable I-port */ + { 0x87, 1, { 0x01 } }, + } + }; + + static const struct cxm_saa7115_command + saa7115_select_fm = { + 1, + { + /* Enable audio clock */ + { 0x88, 1, { 0x33 } } + } + }; + + static const struct cxm_saa7115_command + saa7115_select_line_in_composite = { + 3, + { + /* Amp plus anti-alias filter, CVBS from AI11 */ + { 0x02, 1, { 0xc0 } }, + /* Adaptive luminance comb filter */ + { 0x09, 1, { 0x40 } }, + + /* Enable AD1, audio clock, scaler, decoder */ + { 0x88, 1, { 0x70 } } + } + }; + + static const struct cxm_saa7115_command + saa7115_select_line_in_svideo = { + 3, + { + /* Amp plus anti-alias filter, Y / C from AI11 / AI21 */ + { 0x02, 1, { 0xc8 } }, + /* Bypass chrominance trap / comb filter */ + { 0x09, 1, { 0x80 } }, + + /* Enable AD1 & 2, audio clock, scaler, decoder */ + { 0x88, 1, { 0xf0 } } + } + }; + + static const struct cxm_saa7115_command + saa7115_select_tuner = { + 3, + { + /* Amp plus anti-alias filter, CVBS (auto gain) from AI23 */ + { 0x02, 1, { 0xc4 } }, + /* Adaptive luminance comb filter */ + { 0x09, 1, { 0x40 } }, + + /* Enable AD2, audio clock, scaler, decoder */ + { 0x88, 1, { 0xb0 } } + } + }; + + static const struct cxm_saa7115_command + saa7115_scaler_vcd_ntsc_double_lines = { + 14, + { + /* + * Input window = 720 x 240, output window = 352 x 240 with + * YS extended by 2 as per section 17.4 of the data sheet + * and YO accounting for scaler processing triggering at + * line 5 and active video starting at line 23 (see section + * 8.2 table 8 and section 8.3.1.1 table 11 of the data sheet). + * NTSC active video should actually start at line 22, however + * not all channels / programs do. + */ + { 0x94, 12, { 0x02, 0x00, 0xd0, 0x02, 0x12, 0x00, 0xf2, 0x00, + 0x60, 0x01, 0xf0, 0x00 } }, + + /* Prefiltering and prescaling */ + { 0xa0, 3, { 0x02, 0x02, 0xaa } }, + + /* Brightness, contrast, and saturation */ + { 0xa4, 3, { 0x80, 0x40, 0x40 } }, + + /* Horizontal phase scaling */ + { 0xa8, 3, { 0x18, 0x04, 0x00 } }, + { 0xac, 3, { 0x0c, 0x02, 0x00 } }, + + /* Vertical scaling */ + { 0xb0, 5, { 0x00, 0x04, 0x00, 0x04, 0x00 } }, + + /* Vertical phase offsets */ + { 0xb8, 8, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, + + /* Inverted VGATE start at line 23, stop after line 263 */ + { 0x15, 2, { 0x02, 0x12 } }, + + /* VBI data slicer 525 lines, line 21 is closed caption */ + { 0x54, 2, { 0x4d, 0x00 } }, + { 0x5a, 2, { 0x06, 0x83 } }, + + /* PLL2 525 lines, 27 Mhz target clock */ + { 0xf0, 1, { 0xad } }, + + /* Pulse generator 525 lines, 27 Mhz target clock */ + { 0xf5, 1, { 0xad } }, + + /* Audio clock 44.1 kHz NTSC (using a 32.11 MHz crystal) */ + { 0x30, 3, { 0xbc, 0xdf, 0x02 } }, + { 0x34, 3, { 0xf2, 0x00, 0x2d } }, + } + }; + + static const struct cxm_saa7115_command + saa7115_scaler_vcd_pal_double_lines = { + 14, + { + /* + * Input window = 720 x 288, output window = 352 x 288 with + * YS extended by 2 as per section 17.4 of the data sheet + * and YO accounting for scaler processing triggering at + * line 2 and active video starting at line 25 (see section + * 8.2 table 8 and section 8.3.1.1 table 11 of the data sheet). + * PAL active video should actually start at line 24, however + * not all channels / programs do. + */ + { 0x94, 12, { 0x02, 0x00, 0xd0, 0x02, 0x17, 0x00, 0x22, 0x01, + 0x60, 0x01, 0x20, 0x01 } }, + + /* Prefiltering and prescaling */ + { 0xa0, 3, { 0x02, 0x02, 0xaa } }, + + /* Brightness, contrast, and saturation */ + { 0xa4, 3, { 0x80, 0x40, 0x40 } }, + + /* Horizontal phase scaling */ + { 0xa8, 3, { 0x18, 0x04, 0x00 } }, + { 0xac, 3, { 0x0c, 0x02, 0x00 } }, + + /* Vertical scaling */ + { 0xb0, 5, { 0x00, 0x04, 0x00, 0x04, 0x00 } }, + + /* Vertical phase offsets */ + { 0xb8, 8, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, + + /* Inverted VGATE start at line 25, stop after line 313 */ + { 0x15, 2, { 0x37, 0x17 } }, + + /* VBI data slicer 625 lines, line 22 is closed caption */ + { 0x54, 2, { 0xdd, 0x4d } }, + { 0x5a, 2, { 0x03, 0x03 } }, + + /* PLL2 625 lines, 27 Mhz target clock */ + { 0xf0, 1, { 0xb0 } }, + + /* Pulse generator 625 lines, 27 Mhz target clock */ + { 0xf5, 1, { 0xb0 } }, + + /* Audio clock 44.1 kHz PAL (using a 32.11 MHz crystal) */ + { 0x30, 3, { 0x00, 0x72, 0x03 } }, + { 0x34, 3, { 0xf2, 0x00, 0x2d } }, + } + }; + + static const struct cxm_saa7115_command + saa7115_scaler_svcd_ntsc = { + 14, + { + /* + * Input window = 720 x 240, output window = 480 x 240 with + * YS extended by 2 as per section 17.4 of the data sheet + * and YO accounting for scaler processing triggering at + * line 5 and active video starting at line 23 (see section + * 8.2 table 8 and section 8.3.1.1 table 11 of the data sheet). + * NTSC active video should actually start at line 22, however + * not all channels / programs do. + */ + { 0x94, 12, { 0x02, 0x00, 0xd0, 0x02, 0x12, 0x00, 0xf2, 0x00, + 0xe0, 0x01, 0xf0, 0x00 } }, + + /* Prefiltering and prescaling */ + { 0xa0, 3, { 0x01, 0x00, 0x00 } }, + + /* Brightness, contrast, and saturation */ + { 0xa4, 3, { 0x80, 0x40, 0x40 } }, + + /* Horizontal phase scaling */ + { 0xa8, 3, { 0x00, 0x06, 0x00 } }, + { 0xac, 3, { 0x00, 0x03, 0x00 } }, + + /* Vertical scaling */ + { 0xb0, 5, { 0x00, 0x04, 0x00, 0x04, 0x00 } }, + + /* Vertical phase offsets */ + { 0xb8, 8, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, + + /* Inverted VGATE start at line 23, stop after line 263 */ + { 0x15, 2, { 0x02, 0x12 } }, + + /* VBI data slicer 525 lines, line 21 is closed caption */ + { 0x54, 2, { 0x4d, 0x00 } }, + { 0x5a, 2, { 0x06, 0x83 } }, + + /* PLL2 525 lines, 27 Mhz target clock */ + { 0xf0, 1, { 0xad } }, + + /* Pulse generator 525 lines, 27 Mhz target clock */ + { 0xf5, 1, { 0xad } }, + + /* Audio clock 44.1 kHz NTSC (using a 32.11 MHz crystal) */ + { 0x30, 3, { 0xbc, 0xdf, 0x02 } }, + { 0x34, 3, { 0xf2, 0x00, 0x2d } }, + } + }; + + static const struct cxm_saa7115_command + saa7115_scaler_svcd_pal = { + 14, + { + /* + * Input window = 720 x 288, output window = 480 x 288 with + * YS extended by 2 as per section 17.4 of the data sheet + * and YO accounting for scaler processing triggering at + * line 2 and active video starting at line 25 (see section + * 8.2 table 8 and section 8.3.1.1 table 11 of the data sheet). + * PAL active video should actually start at line 24, however + * not all channels / programs do. + */ + { 0x94, 12, { 0x02, 0x00, 0xd0, 0x02, 0x17, 0x00, 0x22, 0x01, + 0xe0, 0x01, 0x20, 0x01 } }, + + /* Prefiltering and prescaling */ + { 0xa0, 3, { 0x01, 0x00, 0x00 } }, + + /* Brightness, contrast, and saturation */ + { 0xa4, 3, { 0x80, 0x40, 0x40 } }, + + /* Horizontal phase scaling */ + { 0xa8, 3, { 0x00, 0x06, 0x00 } }, + { 0xac, 3, { 0x00, 0x03, 0x00 } }, + + /* Vertical scaling */ + { 0xb0, 5, { 0x00, 0x04, 0x00, 0x04, 0x00 } }, + + /* Vertical phase offsets */ + { 0xb8, 8, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, + + /* Inverted VGATE start at line 25, stop after line 313 */ + { 0x15, 2, { 0x37, 0x17 } }, + + /* VBI data slicer 625 lines, line 22 is closed caption */ + { 0x54, 2, { 0xdd, 0x4d } }, + { 0x5a, 2, { 0x03, 0x03 } }, + + /* PLL2 625 lines, 27 Mhz target clock */ + { 0xf0, 1, { 0xb0 } }, + + /* Pulse generator 625 lines, 27 Mhz target clock */ + { 0xf5, 1, { 0xb0 } }, + + /* Audio clock 44.1 kHz PAL (using a 32.11 MHz crystal) */ + { 0x30, 3, { 0x00, 0x72, 0x03 } }, + { 0x34, 3, { 0xf2, 0x00, 0x2d } }, + } + }; + + static const struct cxm_saa7115_command + saa7115_scaler_dvd_ntsc = { + 14, + { + /* + * Input window = 720 x 240, output window = 720 x 240 with + * YS extended by 2 as per section 17.4 of the data sheet + * and YO accounting for scaler processing triggering at + * line 5 and active video starting at line 23 (see section + * 8.2 table 8 and section 8.3.1.1 table 11 of the data sheet). + * NTSC active video should actually start at line 22, however + * not all channels / programs do. + */ + { 0x94, 12, { 0x02, 0x00, 0xd0, 0x02, 0x12, 0x00, 0xf2, 0x00, + 0xd0, 0x02, 0xf0, 0x00 } }, + + /* Prefiltering and prescaling */ + { 0xa0, 3, { 0x01, 0x00, 0x00 } }, + + /* Brightness, contrast, and saturation */ + { 0xa4, 3, { 0x80, 0x40, 0x40 } }, + + /* Horizontal phase scaling */ + { 0xa8, 3, { 0x00, 0x04, 0x00 } }, + { 0xac, 3, { 0x00, 0x02, 0x00 } }, + + /* Vertical scaling */ + { 0xb0, 5, { 0x00, 0x04, 0x00, 0x04, 0x00 } }, + + /* Vertical phase offsets */ + { 0xb8, 8, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, + + /* Inverted VGATE start at line 23, stop after line 263 */ + { 0x15, 2, { 0x02, 0x12 } }, + + /* VBI data slicer 525 lines, line 21 is closed caption */ + { 0x54, 2, { 0x4d, 0x00 } }, + { 0x5a, 2, { 0x06, 0x83 } }, + + /* PLL2 525 lines, 27 Mhz target clock */ + { 0xf0, 1, { 0xad } }, + + /* Pulse generator 525 lines, 27 Mhz target clock */ + { 0xf5, 1, { 0xad } }, + + /* Audio clock 48 kHz NTSC (using a 32.11 MHz crystal) */ + { 0x30, 3, { 0xcd, 0x20, 0x03 } }, + { 0x34, 3, { 0xce, 0xfb, 0x30 } }, + } + }; + + static const struct cxm_saa7115_command + saa7115_scaler_dvd_pal = { + 14, + { + /* + * Input window = 720 x 288, output window = 720 x 288 with + * YS extended by 2 as per section 17.4 of the data sheet + * and YO accounting for scaler processing triggering at + * line 2 and active video starting at line 25 (see section + * 8.2 table 8 and section 8.3.1.1 table 11 of the data sheet). + * PAL active video should actually start at line 24, however + * not all channels / programs do. + */ + { 0x94, 12, { 0x02, 0x00, 0xd0, 0x02, 0x17, 0x00, 0x22, 0x01, + 0xd0, 0x02, 0x20, 0x01 } }, + + /* Prefiltering and prescaling */ + { 0xa0, 3, { 0x01, 0x00, 0x00 } }, + + /* Brightness, contrast, and saturation */ + { 0xa4, 3, { 0x80, 0x40, 0x40 } }, + + /* Horizontal phase scaling */ + { 0xa8, 3, { 0x00, 0x04, 0x00 } }, + { 0xac, 3, { 0x00, 0x02, 0x00 } }, + + /* Vertical scaling */ + { 0xb0, 5, { 0x00, 0x04, 0x00, 0x04, 0x00 } }, + + /* Vertical phase offsets */ + { 0xb8, 8, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, + + /* Inverted VGATE start at line 25, stop after line 313 */ + { 0x15, 2, { 0x37, 0x17 } }, + + /* VBI data slicer 625 lines, line 22 is closed caption */ + { 0x54, 2, { 0xdd, 0x4d } }, + { 0x5a, 2, { 0x03, 0x03 } }, + + /* PLL2 625 lines, 27 Mhz target clock */ + { 0xf0, 1, { 0xb0 } }, + + /* Pulse generator 625 lines, 27 Mhz target clock */ + { 0xf5, 1, { 0xb0 } }, + + /* Audio clock 48 kHz PAL (using a 32.11 MHz crystal) */ + { 0x30, 3, { 0x00, 0xc0, 0x03 } }, + { 0x34, 3, { 0xce, 0xfb, 0x30 } }, + } + }; + + static const struct cxm_saa7115_scaling + saa7115_scalings[] = { + { 352, 480, &saa7115_scaler_vcd_ntsc_double_lines }, + { 352, 576, &saa7115_scaler_vcd_pal_double_lines }, + { 480, 480, &saa7115_scaler_svcd_ntsc }, + { 480, 576, &saa7115_scaler_svcd_pal }, + { 720, 480, &saa7115_scaler_dvd_ntsc }, + { 720, 576, &saa7115_scaler_dvd_pal } + }; + + /* Reset the SAA7115 chip */ + static int + cxm_saa7115_reset( device_t iicbus, int i2c_addr ) + { + unsigned char msg[2]; + int sent; + + /* put into reset mode */ + msg[0] = 0x88; + msg[1] = 0x0b; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + iicbus_stop(iicbus); + + /* put back to operational mode */ + msg[0] = 0x88; + msg[1] = 0x2b; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + iicbus_stop(iicbus); + + return 0; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + /* Read from the SAA7115 registers */ + static int + cxm_saa7115_read( device_t iicbus, int i2c_addr, + unsigned char addr, char *buf, int len ) + { + unsigned char msg[1]; + int received; + int sent; + + msg[0] = addr; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + if (iicbus_repeated_start(iicbus, i2c_addr + 1, CXM_I2C_TIMEOUT) != 0) + goto fail; + + if (iicbus_read(iicbus, buf, len, &received, IIC_LAST_READ, 0) != 0) + goto fail; + + iicbus_stop(iicbus); + + return received; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + /* Write to the SAA7115 registers */ + static int + cxm_saa7115_write( device_t iicbus, int i2c_addr, + unsigned char addr, const char *buf, int len ) + { + unsigned char msg[1]; + int sent; + + msg[0] = addr; + + if (iicbus_start(iicbus, i2c_addr, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_write(iicbus, msg, sizeof(msg), &sent, CXM_I2C_TIMEOUT) != 0 + || sent != sizeof(msg)) + goto fail; + + if (iicbus_write(iicbus, buf, len, &sent, CXM_I2C_TIMEOUT) != 0) + goto fail; + + iicbus_stop(iicbus); + + return sent; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + int + cxm_saa7115_init( struct cxm_softc *sc ) + { + unsigned char rev[1]; + unsigned int i; + unsigned int nsettings; + const struct cxm_saa7115_setting *settings; + + if (cxm_saa7115_reset (sc->iicbus, CXM_I2C_SAA7115) < 0) + return -1; + + if (cxm_saa7115_read(sc->iicbus, CXM_I2C_SAA7115, 0x00, + rev, sizeof(rev)) != sizeof(rev)) + return -1; + + nsettings = saa7115_init.nsettings; + settings = saa7115_init.settings; + + for (i = 0; i < nsettings; i++) + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, + settings[i].addr, + settings[i].values, settings[i].nvalues) + != settings[i].nvalues) + return -1; + + if (cxm_saa7115_select_source(sc, cxm_tuner_source) < 0) + return -1; + + printf("%s: SAA7115 rev %u video decoder\n", + sc->name, (unsigned int)rev[0] >> 4); + + return 0; + } + + + int + cxm_saa7115_mute( struct cxm_softc *sc ) + { + unsigned int i; + unsigned int nsettings; + const struct cxm_saa7115_setting *settings; + + nsettings = saa7115_mute.nsettings; + settings = saa7115_mute.settings; + + for (i = 0; i < nsettings; i++) + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, + settings[i].addr, + settings[i].values, settings[i].nvalues) + != settings[i].nvalues) + return -1; + + return 0; + } + + + int + cxm_saa7115_unmute( struct cxm_softc *sc ) + { + unsigned int i; + unsigned int nsettings; + const struct cxm_saa7115_setting *settings; + + nsettings = saa7115_unmute.nsettings; + settings = saa7115_unmute.settings; + + for (i = 0; i < nsettings; i++) + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, + settings[i].addr, + settings[i].values, settings[i].nvalues) + != settings[i].nvalues) + return -1; + + return 0; + } + + + int + cxm_saa7115_select_source( struct cxm_softc *sc, enum cxm_source source ) + { + unsigned int i; + unsigned int nsettings; + const struct cxm_saa7115_setting *settings; + + switch (source) { + case cxm_fm_source: + nsettings = saa7115_select_fm.nsettings; + settings = saa7115_select_fm.settings; + break; + + case cxm_line_in_source_composite: + nsettings = saa7115_select_line_in_composite.nsettings; + settings = saa7115_select_line_in_composite.settings; + break; + + case cxm_line_in_source_svideo: + nsettings = saa7115_select_line_in_svideo.nsettings; + settings = saa7115_select_line_in_svideo.settings; + break; + + case cxm_tuner_source: + nsettings = saa7115_select_tuner.nsettings; + settings = saa7115_select_tuner.settings; + break; + + default: + return -1; + } + + for (i = 0; i < nsettings; i++) + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, + settings[i].addr, + settings[i].values, settings[i].nvalues) + != settings[i].nvalues) + return -1; + + return 0; + } + + + int + cxm_saa7115_configure_scaler( struct cxm_softc *sc, + unsigned int width, unsigned int height ) + { + unsigned char power[1]; + unsigned char task[1]; + unsigned int i; + unsigned int nsettings; + const struct cxm_saa7115_setting *settings; + + for (i = 0; NUM_ELEMENTS(saa7115_scalings); i++) + if (saa7115_scalings[i].width == width + && saa7115_scalings[i].height == height) + break; + + if (i >= NUM_ELEMENTS(saa7115_scalings)) + return -1; + + nsettings = saa7115_scalings[i].scaling->nsettings; + settings = saa7115_scalings[i].scaling->settings; + + /* + * Reset scaler. + */ + + if (cxm_saa7115_read(sc->iicbus, CXM_I2C_SAA7115, 0x88, + power, sizeof(power)) != sizeof(power)) + return -1; + + power[0] &= ~0x20; + + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, 0x88, + power, sizeof(power)) != sizeof(power)) + return -1; + + /* + * Configure scaler. + */ + + for (i = 0; i < nsettings; i++) + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, + settings[i].addr, + settings[i].values, settings[i].nvalues) + != settings[i].nvalues) + return -1; + + /* + * Enable task register set A. + */ + + if (cxm_saa7115_read(sc->iicbus, CXM_I2C_SAA7115, 0x80, + task, sizeof(task)) != sizeof(task)) + return -1; + + task[0] |= 0x10; + + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, 0x80, + task, sizeof(task)) != sizeof(task)) + return -1; + + /* + * Enable scaler. + */ + + if (cxm_saa7115_read(sc->iicbus, CXM_I2C_SAA7115, 0x88, + power, sizeof(power)) != sizeof(power)) + return -1; + + power[0] |= 0x20; + + if (cxm_saa7115_write(sc->iicbus, CXM_I2C_SAA7115, 0x88, + power, sizeof(power)) != sizeof(power)) + return -1; + + return 0; + } + + + enum cxm_source_format + cxm_saa7115_detected_format( struct cxm_softc *sc ) + { + unsigned char status[2]; + enum cxm_source_format source_format; + + if (cxm_saa7115_read(sc->iicbus, CXM_I2C_SAA7115, 0x1e, + status, sizeof(status)) != sizeof(status)) + return cxm_unknown_source_format; + + if (! (status[1] & 0x01) ) + return cxm_unknown_source_format; + + source_format = cxm_unknown_source_format; + + if (! (status[1] & 0x40) ) + switch (status[0] & 0x03) { + case 0: + source_format = cxm_bw_50hz_source_format; + break; + + case 1: + source_format = cxm_ntsc_50hz_source_format; + break; + + case 2: + source_format = cxm_pal_50hz_source_format; + break; + + case 3: + source_format = cxm_secam_50hz_source_format; + break; + + default: + break; + } + else + switch (status[0] & 0x03) { + case 0: + source_format = cxm_bw_60hz_source_format; + break; + + case 1: + source_format = cxm_ntsc_60hz_source_format; + break; + + case 2: + source_format = cxm_pal_60hz_source_format; + break; + + default: + break; + } + + return source_format; + } + + + int + cxm_saa7115_detected_fps( struct cxm_softc *sc ) + { + unsigned char status[1]; + + if (cxm_saa7115_read(sc->iicbus, CXM_I2C_SAA7115, 0x1f, + status, sizeof(status)) != sizeof(status)) + return -1; + + if (! (status[0] & 0x01) ) + return -1; + + return (status[0] & 0x20) ? 30 : 25; + } + + + int + cxm_saa7115_is_locked( struct cxm_softc *sc ) + { + unsigned char status[1]; + + if (cxm_saa7115_read(sc->iicbus, CXM_I2C_SAA7115, 0x1f, + status, sizeof(status)) != sizeof(status)) + return -1; + + return (status[0] & 0x01) ? 1 : 0; + } + + + int + cxm_saa7115_wait_for_lock( struct cxm_softc *sc ) + { + unsigned int i; + + /* + * Section 2.7 of the data sheet states: + * + * Ultra-fast frame lock (almost 1 field) + * + * so hopefully 300 ms is enough (the lock + * sometimes takes a long time to occur ... + * possibly due to the time it takes to + * autodetect the format). + */ + + for (i = 0; i < 6; i++) { + + /* + * The input may have just change (prior to + * cxm_saa7115_wait_for_lock) so start with + * the delay to give the video decoder a + * chance to update it's status. + */ + + tsleep(&sc->iicbus, PZERO, "video", hz / 20 ); + + switch (cxm_saa7115_is_locked(sc)) { + case 1: + return 1; + + case 0: + break; + + default: + return -1; + } + } + + printf("%s: video decoder failed to lock\n", sc->name); + + return -1; + } *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm_ir.c Sat Nov 15 22:16:24 2003 *************** *** 0 **** --- 1,123 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Infrared remote routines for the Conexant MPEG-2 Codec driver. + * + * Ideally these routines should be implemented as a separate + * driver which has a generic infrared remote interface so that + * it's not necessary for each multimedia driver to re-invent + * the wheel. + */ + + + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + + #include + #include + + #include + + #include + #include + + #include "iicbb_if.h" + + + static int + cxm_ir_read( device_t iicbus, int i2c_addr, char *buf, int len ) + { + int received; + + if (iicbus_start(iicbus, i2c_addr + 1, CXM_I2C_TIMEOUT) != 0) + return -1; + + if (iicbus_read(iicbus, buf, len, &received, IIC_LAST_READ, 0) != 0) + goto fail; + + iicbus_stop(iicbus); + + return received; + + fail: + iicbus_stop(iicbus); + return -1; + } + + + int + cxm_ir_init( struct cxm_softc *sc ) + { + unsigned char key[1]; + + if (cxm_ir_read(sc->iicbus, CXM_I2C_IR, + key, sizeof(key)) != sizeof(key)) + return -1; + + printf("%s: IR Remote\n", sc->name); + + return 0; + } + + + int + cxm_ir_key( struct cxm_softc *sc, char *buf, int len ) + { + int result; + + result = cxm_ir_read(sc->iicbus, CXM_I2C_IR, buf, len); + + if (result >= 0) + return result; + + /* + * If the IR receiver didn't respond, + * then wait 50 ms and try again. + */ + + tsleep(&sc->iicbus, PZERO, "IR", hz / 20 ); + + return cxm_ir_read(sc->iicbus, CXM_I2C_IR, buf, len); + } *** /dev/null Fri Dec 5 00:21:23 2003 --- dev/cxm/cxm_extract_fw.c Fri Dec 5 00:34:15 2003 *************** *** 0 **** --- 1,215 ---- + /* + * Copyright (c) 2003 + * John Wehle . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Wehle. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Conexant MPEG-2 Codec firmware extraction program. + * + * Generates cxm_dec_fw.c and cxm_enc_fw.c from the + * Hauppauge PVR-250 / PVR-350 Microsoft Windows driver + * (i.e. hcwpvrp2.sys). + * + * This was written using the invaluable information + * compiled by The IvyTV Project (ivtv.sourceforge.net). + */ + + #include + #include + #include + #include + #include + #include + #include + #include + + + const char *MyName = "cxm_extract_fw"; + + const u_int8_t decoder_magic[] = { + 0xa7, 0x03, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa }; + const u_int8_t encoder_magic[] = { + 0xa7, 0x0d, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa }; + + + static int + save_firmware (const char *name, const u_int8_t *buf, size_t nbytes) + { + FILE *ofp; + char outfile[MAXPATHLEN]; + size_t i; + + if (nbytes < (256 * 1024)) { + fprintf (stderr, "%s: save_firmware -- firmware image isn't long enough\n", + MyName); + return -1; + } + + if (snprintf (outfile, sizeof (outfile), "%s.c", name) >= sizeof (outfile)) { + fprintf (stderr, "%s: save_firmware -- firmware name is too long\n", + MyName); + return -1; + } + + if (! (ofp = fopen (outfile, "w")) ) { + fprintf (stderr, "%s: save_firmware -- can't open output file <%s>\n", + MyName, outfile); + perror (MyName); + return -1; + } + + fprintf (ofp, "#include \n" + "\n" + "const u_int8_t %s[] __attribute__ ((aligned(4))) = {", + name); + + for (i = 0; i < (256 * 1024); i++) { + if (i) + fputc (',', ofp); + if ((i % 8) == 0) + fputs ("\n\t", ofp); + else + fputc (' ', ofp); + fprintf (ofp, "0x%.2x", buf[i]); + } + + fprintf (ofp, "\n};\n"); + + if (ferror (ofp)) { + fclose (ofp); + return -1; + } + + fclose (ofp); + return 0; + } + + + int + main (int argc, char **argv) + { + const char *infile; + const u_int8_t *end; + const u_int8_t *ptr; + const u_int8_t *start; + int decoder_fw_saved; + int encoder_fw_saved; + int fd; + struct stat statbuf; + + if (argc != 2) { + fprintf (stderr, "Usage: %s \n", MyName); + exit (1); + } + + infile = argv[1]; + + /* + * Open the file. + */ + + if ((fd = open (infile, O_RDONLY)) < 0) { + fprintf (stderr, "%s: can't open %s for reading\n", MyName, infile); + perror (MyName); + exit (1); + } + + /* + * Determine how big it is. + */ + + if (fstat (fd, &statbuf) < 0) { + fprintf (stderr, "%s: can't fstat %s\n", MyName, infile); + perror (MyName); + close (fd); + exit (1); + } + + /* + * Map it into memory. + */ + + if ( !(start = (u_int8_t *)mmap (NULL, (size_t)statbuf.st_size, + PROT_READ, MAP_SHARED, fd, (off_t)0)) ) { + fprintf (stderr, "%s: can't mmap %s\n", MyName, infile); + perror (MyName); + close (fd); + exit (1); + } + + end = start + statbuf.st_size; + + close (fd); + + decoder_fw_saved = 0; + encoder_fw_saved = 0; + + for (ptr = start; ptr != end; ptr++) { + if ((end - ptr) >= sizeof (decoder_magic) + && memcmp (ptr, decoder_magic, sizeof (decoder_magic)) == 0) + if (! decoder_fw_saved) { + if (save_firmware ("cxm_dec_fw", ptr, end - ptr) < 0) { + fprintf (stderr, "%s: save_firmware failed\n", MyName); + exit (1); + } + decoder_fw_saved = 1; + } + else { + fprintf (stderr, "%s: multiple decoder images present\n", MyName); + exit (1); + } + + if ((end - ptr) >= sizeof (encoder_magic) + && memcmp (ptr, encoder_magic, sizeof (encoder_magic)) == 0) + if (! encoder_fw_saved) { + if (save_firmware ("cxm_enc_fw", ptr, end - ptr) < 0) { + fprintf (stderr, "%s: save_firmware failed\n", MyName); + exit (1); + } + encoder_fw_saved = 1; + } + else { + fprintf (stderr, "%s: multiple encoder images present\n", MyName); + exit (1); + } + } + + munmap ((caddr_t)start, (size_t)statbuf.st_size); + + if (! decoder_fw_saved) + fprintf (stderr, "%s: decoder image not present\n", MyName); + + if (! encoder_fw_saved) + fprintf (stderr, "%s: encoder image not present\n", MyName); + + if (! decoder_fw_saved || ! encoder_fw_saved) + exit (1); + + exit (0); + } *** /dev/null Fri Dec 5 00:21:23 2003 --- modules/cxm/Makefile Wed Sep 24 02:45:37 2003 *************** *** 0 **** --- 1,5 ---- + SUBDIR = + SUBDIR += cxm + SUBDIR += cxm_iic + + .include *** /dev/null Fri Dec 5 00:21:23 2003 --- modules/cxm/cxm/Makefile Sat Nov 15 20:18:51 2003 *************** *** 0 **** --- 1,7 ---- + .PATH: ${.CURDIR}/../../../dev/cxm + KMOD = cxm + SRCS = cxm.c cxm.h cxm_dec_fw.c cxm_enc_fw.c cxm_audio.c cxm_eeprom.c \ + cxm_ir.c cxm_tuner.c cxm_video.c opt_cxm.h \ + bus_if.h device_if.h iicbb_if.h pci_if.h vnode_if.h + + .include *** /dev/null Fri Dec 5 00:21:23 2003 --- modules/cxm/cxm_iic/Makefile Wed Sep 24 01:59:24 2003 *************** *** 0 **** --- 1,6 ---- + .PATH: ${.CURDIR}/../../../dev/cxm + KMOD = cxm_iic + SRCS = cxm_i2c.c cxm.h \ + opt_cxm.h bus_if.h device_if.h iicbb_if.h pci_if.h + + .include ------------------------------------------------------------------------- | Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | | John Wehle | Fax: 1-215-540-5495 | | ------------------------------------------------------------------------- From owner-freebsd-multimedia@FreeBSD.ORG Thu Dec 4 22:31:28 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D4D7A16A4CE for ; Thu, 4 Dec 2003 22:31:28 -0800 (PST) Received: from feith1.FEITH.COM (feith1.FEITH.COM [192.251.93.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2140143FBD for ; Thu, 4 Dec 2003 22:31:26 -0800 (PST) (envelope-from john@feith.com) Received: from jwlab.FEITH.COM (jwlab.FEITH.COM [192.251.93.16]) by feith1.FEITH.COM (8.12.10+Sun/8.12.9) with ESMTP id hB56VOOI019310; Fri, 5 Dec 2003 01:31:25 -0500 (EST) Received: (from john@localhost) by jwlab.FEITH.COM (8.11.7+Sun/8.11.7) id hB56VOq00469; Fri, 5 Dec 2003 01:31:24 -0500 (EST) Date: Fri, 5 Dec 2003 01:31:24 -0500 (EST) From: John Wehle Message-Id: <200312050631.hB56VOq00469@jwlab.FEITH.COM> To: jmg@gate.funkthat.com Content-Type: text X-Scanned-By: MIMEDefang 2.39 X-Archived: cashew.FEITH.COM cc: multimedia@freebsd.org Subject: Re: Hauppauge PVR-250 / 350 Driver X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2003 06:31:28 -0000 > Any work on integrating it with one of the many PVR programs out there? No, though it shouldn't require a lot of work. Currently I use a homegrown VCR program built out of PHP and C. For playback I use mplayer or WinDVD. > Because I assume that the card can only captuer sound as part of the mpeg > codec stream? That is the normal operating mode for the card. The API documentation indicates raw audio and video capture is possible. However this of course requires more bandwidth, increases the risk of frame drops, and risks audio / video sychronization problems. -- John ------------------------------------------------------------------------- | Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | | John Wehle | Fax: 1-215-540-5495 | | ------------------------------------------------------------------------- From owner-freebsd-multimedia@FreeBSD.ORG Fri Dec 5 11:26:50 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8074116A4D1 for ; Fri, 5 Dec 2003 11:26:50 -0800 (PST) Received: from server2.teleport.ch (server2.teleport.ch [157.161.16.254]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5469543FB1 for ; Fri, 5 Dec 2003 11:26:48 -0800 (PST) (envelope-from espen@teleport.ch) Received: from pimp.intern-lan (cable-rhf1-061.teleport.ch [157.161.32.61]) by server2.teleport.ch (8.12.9p2/8.12.9) with SMTP id hB5JQi2M046276 for ; Fri, 5 Dec 2003 20:26:45 +0100 (CET) (envelope-from espen@teleport.ch) Date: Fri, 5 Dec 2003 20:28:52 +0100 From: Espen Jervidalo To: multimedia@freebsd.org Message-Id: <20031205202852.2576e196.espen@teleport.ch> X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i386-portbld-freebsd5.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: mplayer -tv with bsdbt848 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2003 19:26:50 -0000 hi list, i have been trying to get mplayer working with my Hauppauge WinTV card without success, although it works fine with xawtv and fxtv. the command i think should be right is as follows (but i've tried almost any other combination): mplayer -tv on:driver=bsdbt848:norm=paln:chanlist=europe-west:input=1 sound works, but the picture hangs and looks odd (some green and blue mixed up stuff), still i'm able to recognize the mtv logo f.e. i tried all kind of video output possibilties, including aa and xv. xv works great with other media on mplayer, so i don't think the problem lies there, but i might be wrong. perhaps some trouble with screen resolutions? i would really appreciate help on this one. google didn't help much either. have a nice weekend. greetings, espen jervidalo bktr0: mem 0xdddfe000-0xdddfefff irq 12 at device 7.0 on pci0 bktr0: Hauppauge Model 38074 B421 bktr0: Hauppauge WinCast/TV, Philips FR1216 PAL FM tuner, remote control. FreeBSD 5.1-RELEASE #2: Sat Sep 20 17:22:14 CEST 2003 root@pimp.intern-lan:/usr/src/sys/i386/compile/PIMP Preloaded elf kernel "/boot/kernel/kernel" at 0xc0708000. Preloaded elf module "/boot/kernel/nvidia.ko" at 0xc0708244. Preloaded elf module "/boot/kernel/linux.ko" at 0xc07082f0. Preloaded elf module "/boot/kernel/acpi.ko" at 0xc070839c. Timecounter "i8254" frequency 1193182 Hz Timecounter "TSC" frequency 1003655968 Hz CPU: AMD Duron(tm) Processor (1003.66-MHz 686-class CPU) Origin = "AuthenticAMD" Id = 0x631 Stepping = 1 Features=0x183fbff AMD Features=0xc0440000 real memory = 536805376 (511 MB) avail memory = 513802240 (490 MB) Pentium Pro MTRR support enabled npx0: on motherboard npx0: INT 16 interface acpi0: on motherboard pcibios: BIOS version 2.10 Using $PIR table, 14 entries at 0xc00f8030 acpi0: power button is handled as a fixed feature programming model. Timecounter "ACPI-fast" frequency 3579545 Hz acpi_timer0: <24-bit timer at 3.579545MHz> port 0x808-0x80b on acpi0 acpi_cpu0: on acpi0 acpi_button0: on acpi0 pcib0: port 0xcf8-0xcff on acpi0 pci0: on pcib0 agp0: mem 0xe0000000-0xe7ffffff at device 0.0 on pci0 pcib1: at device 1.0 on pci0 pci1: on pcib1 nvidia0: mem 0xda000000-0xdbffffff,0xde000000-0xdeffffff irq 11 at device 0.0 on pci1 bktr0: mem 0xdddfe000-0xdddfefff irq 12 at device 7.0 on pci0 bktr0: Hauppauge Model 38074 B421 bktr0: Hauppauge WinCast/TV, Philips FR1216 PAL FM tuner, remote control. pci0: at device 7.1 (no driver attached) xl0: <3Com 3c905B-TX Fast Etherlink XL> port 0xe800-0xe87f mem 0xdfffef80-0xdfffefff irq 5 at device 10.0 on pci0 xl0: Ethernet address: 00:50:04:66:14:04 miibus0: on xl0 xlphy0: <3Com internal media interface> on miibus0 xlphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto ahc0: port 0xec00-0xecff mem 0xdffff000-0xdfffffff irq 10 at device 11.0 on pci0 aic7880: Ultra Single Channel A, SCSI Id=7, 16/253 SCBs pcm0: port 0xe400-0xe4ff irq 11 at device 12.0 on pci0 atapci0: port 0xd800-0xd87f,0xdc00-0xdc0f,0xe000-0xe03f mem 0xdffa0000-0xdffbffff,0xdfffd000-0xdfffdfff irq 12 at device 13.0 on pci0 ata2: at 0xdfffd000 on atapci0 ata3: at 0xdfffd000 on atapci0 ata4: at 0xdfffd000 on atapci0 uhci0: port 0xd000-0xd01f irq 11 at device 16.0 on pci0 usb0: on uhci0 usb0: USB revision 1.0 uhub0: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered uhci1: port 0xd400-0xd41f irq 5 at device 16.1 on pci0 usb1: on uhci1 usb1: USB revision 1.0 uhub1: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub1: 2 ports with 2 removable, self powered ums0: Logitech USB-PS/2 Mouse M-BA47, rev 1.00/1.20, addr 2, iclass 3/1 ums0: 4 buttons and Z dir. pci0: at device 16.3 (no driver attached) isab0: at device 17.0 on pci0 isa0: on isab0 atapci1: port 0xfc00-0xfc0f at device 17.1 on pci0 ata0: at 0x1f0 irq 14 on atapci1 ata1: at 0x170 irq 15 on atapci1 acpi_button1: on acpi0 fdc0: cmd 3 failed at out byte 1 of 3 sio0 port 0x3f8-0x3ff irq 4 on acpi0 sio0: type 16550A sio1 port 0x2f8-0x2ff irq 3 on acpi0 sio1: type 16550A ppc0 port 0x778-0x77b,0x378-0x37f irq 7 drq 3 on acpi0 ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/9 bytes threshold ppbus0: on ppc0 plip0: on ppbus0 lpt0: on ppbus0 lpt0: Interrupt-driven port ppi0: on ppbus0 atkbdc0: port 0x64,0x60 irq 1 on acpi0 atkbd0: flags 0x1 irq 1 on atkbdc0 kbd0 at atkbd0 fdc0: cmd 3 failed at out byte 1 of 3 pmtimer0 on isa0 fdc0: cannot reserve I/O port range (6 ports) sc0: at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> vga0: at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 Timecounters tick every 10.000 msec acpi_cpu: throttling enabled, 16 steps (100% to 6.2%), currently 100.0% ad0: 78167MB [158816/16/63] at ata0-master UDMA100 ad3: 76319MB [155061/16/63] at ata1-slave UDMA100 acd0: DVD-ROM at ata1-master UDMA33 Mounting root from ufs:/dev/ad3s1a cd0 at ahc0 bus 0 target 3 lun 0 cd0: Removable CD-ROM SCSI-2 device cd0: 10.000MB/s transfers (10.000MHz, offset 15) cd0: Attempt to query device size failed: NOT READY, Medium not present From owner-freebsd-multimedia@FreeBSD.ORG Fri Dec 5 12:03:23 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD2E816A4CE for ; Fri, 5 Dec 2003 12:03:23 -0800 (PST) Received: from theinternet.com.au (c211-30-103-113.carlnfd1.nsw.optusnet.com.au [211.30.103.113]) by mx1.FreeBSD.org (Postfix) with ESMTP id 03A2143FDF for ; Fri, 5 Dec 2003 12:03:16 -0800 (PST) (envelope-from akm@theinternet.com.au) Received: from theinternet.com.au (akm@localhost [127.0.0.1]) by theinternet.com.au (8.12.9/8.12.9) with ESMTP id hB5K3D6k002728; Sat, 6 Dec 2003 07:03:13 +1100 (EST) (envelope-from akm@theinternet.com.au) Received: (from akm@localhost) by theinternet.com.au (8.12.9/8.12.9/Submit) id hB5K3DPo002727; Sat, 6 Dec 2003 07:03:13 +1100 (EST) Date: Sat, 6 Dec 2003 07:03:13 +1100 From: Andrew Kenneth Milton To: Espen Jervidalo Message-ID: <20031205200313.GG65894@zeus.theinternet.com.au> References: <20031205202852.2576e196.espen@teleport.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031205202852.2576e196.espen@teleport.ch> User-Agent: Mutt/1.4.1i cc: multimedia@freebsd.org Subject: Re: mplayer -tv with bsdbt848 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2003 20:03:23 -0000 +-------[ Espen Jervidalo ]---------------------- | hi list, | | i have been trying to get mplayer working with my Hauppauge WinTV card without success, although it works fine with xawtv and fxtv. | the command i think should be right is as follows (but i've tried almost any other combination): | | mplayer -tv on:driver=bsdbt848:norm=paln:chanlist=europe-west:input=1 the bsdbt848 driver in mplayer perdy much only knows about norm=pal, norm=ntsc, and norm=secam try using pal instead of paln -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | M:+61 416 022 411 | ACN: 082 081 472 ABN: 83 082 081 472 |akm@theinternet.com.au| Carpe Daemon From owner-freebsd-multimedia@FreeBSD.ORG Fri Dec 5 14:48:26 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E073916A4CE; Fri, 5 Dec 2003 14:48:26 -0800 (PST) Received: from mailgate.rz.uni-karlsruhe.de (mailgate.rz.uni-karlsruhe.de [129.13.64.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9507943FDD; Fri, 5 Dec 2003 14:48:25 -0800 (PST) (envelope-from riggs@o503.hadiko.de) Received: from o503.hadiko.de (hadio503.hadiko.uni-karlsruhe.de [172.20.45.138]) by mailgate.rz.uni-karlsruhe.de with esmtp (Exim 3.36 #1) id 1ASOkK-0005FC-00; Fri, 05 Dec 2003 23:48:24 +0100 Received: from o503.hadiko.de (RIXT@localhost [127.0.0.1]) by o503.hadiko.de (8.12.9p1/8.12.9) with ESMTP id hB5MmOhd060878; Fri, 5 Dec 2003 23:48:24 +0100 (CET) (envelope-from riggs@o503.hadiko.de) Received: (from riggs@localhost) by o503.hadiko.de (8.12.9p1/8.12.9/Submit) id hB5MmNDY060877; Fri, 5 Dec 2003 23:48:23 +0100 (CET) (envelope-from riggs) Date: Fri, 5 Dec 2003 23:48:23 +0100 From: "Thomas E. Zander" To: ports@freebsd.org, multimedia@freebsd.org Message-ID: <20031205224823.GB59259@o503.hadiko.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GID0FwUMdk1T2AWN" Content-Disposition: inline Organization: RiggiServ - Ihr Partner =?iso-8859-15?Q?f?= =?iso-8859-15?Q?=FCr?= alles Delikate X-PGP-KeyID: 0xC85996CD X-PGP-URI: http://blackhole.pca.dfn.de:11371/pks/lookup?op=get&search=0xC85996CD X-PGP-Fingerprint: 4F59 75B4 4CE3 3B00 BC61 5400 8DD4 8929 C859 96CD X-Mailer: Riggisoft Ausguck Eggsbress (Build 1070663720) X-Operating-System: Riggiland BSD 5.1-RELEASE-p11 (To serve and protect.) cc: espen@teleport.ch Subject: Testers needed: mplayer+bt848 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2003 22:48:27 -0000 --GID0FwUMdk1T2AWN Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, if you use mplayer with your tv tuner card and you encounter problems since mplayer jumped from 0.90 to 0.92, would you please try this port http://www.stud.uni-karlsruhe.de/~uedc/mplayer/mplayer.tar.bz2 instead of the standard one? It contains a patch by Simun Mikecin which could resolve some problems. Thanks, Riggs --=20 - "[...] I talked to the computer at great length and -- explained my view of the Universe to it" said Marvin. --- And what happened?" pressed Ford. ---- "It committed suicide." said Marvin. --GID0FwUMdk1T2AWN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- iD8DBQE/0Qs3jdSJKchZls0RAoBUAJ9ZEKKUiHc4BqlkNV3xtmxM4elv9gCfXwZU S+8FD7CUFmucMNVfnBMevuw= =bZdM -----END PGP SIGNATURE----- --GID0FwUMdk1T2AWN-- From owner-freebsd-multimedia@FreeBSD.ORG Fri Dec 5 19:10:12 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A09AE16A4CE for ; Fri, 5 Dec 2003 19:10:12 -0800 (PST) Received: from smtp-out7.blueyonder.co.uk (smtp-out7.blueyonder.co.uk [195.188.213.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 364ED43F85 for ; Fri, 5 Dec 2003 19:10:10 -0800 (PST) (envelope-from steve@pepcross.dyndns.org) Received: from pepcross.dyndns.org ([82.33.91.44]) by smtp-out7.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.5600); Sat, 6 Dec 2003 03:10:16 +0000 Received: (from steve@localhost) by pepcross.dyndns.org (8.12.9/8.12.9/Submit) id hB63AKoa001095; Sat, 6 Dec 2003 03:10:20 GMT Date: Sat, 6 Dec 2003 03:10:20 +0000 From: Steve Roome To: Espen Jervidalo Message-ID: <20031206031020.GC534@dylan.home> References: <20031205202852.2576e196.espen@teleport.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031205202852.2576e196.espen@teleport.ch> User-Agent: Mutt/1.4.1i X-OriginalArrivalTime: 06 Dec 2003 03:10:16.0954 (UTC) FILETIME=[793D6DA0:01C3BBA6] cc: multimedia@freebsd.org Subject: Re: mplayer -tv with bsdbt848 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2003 03:10:12 -0000 On Fri, Dec 05, 2003 at 08:28:52PM +0100, Espen Jervidalo wrote: > hi list, > > i have been trying to get mplayer working with my Hauppauge WinTV > card without success, although it works fine with xawtv and fxtv. > the command i think should be right is as follows (but i've tried > almost any other combination): > > mplayer -tv on:driver=bsdbt848:norm=paln:chanlist=europe-west:input=1 How about something like... mplayer -tv on:input=1:chanlist=europe-west:driver=bsdbt848:channel=S22 -vo x11 (without the norm=paln bit. ) I found mplayer does seem to be so slow with full size PAL that I will generally run with width and height set to half-size instead. Also my tuner seems to default to being the right format (It's a hauppage/pinnacle/miro "pctv" board) but I'm in England. Also, you might be able to use -vo aa and stream it over a compressed (e.g ssh) connection to impress your cow-orkers. In my experience people are usually quite surprised to find you watching telly in the office. from home. In the end I've written my own tv viewing program instead. It's not good, but it doesn't do overlay, just does straight XImages and never ever causes my hardware to crash, which after having 5 different TV cards in FreeBSD for a long time (since 2.x) I've found everything else does cause crashes occasionally. (I think it's overlay or Xv or something ?) Of course, YMMV. :) Steve From owner-freebsd-multimedia@FreeBSD.ORG Fri Dec 5 20:23:00 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4992616A4CE for ; Fri, 5 Dec 2003 20:23:00 -0800 (PST) Received: from theinternet.com.au (c211-30-103-113.carlnfd1.nsw.optusnet.com.au [211.30.103.113]) by mx1.FreeBSD.org (Postfix) with ESMTP id 078B643FE0 for ; Fri, 5 Dec 2003 20:22:54 -0800 (PST) (envelope-from akm@theinternet.com.au) Received: from theinternet.com.au (akm@localhost [127.0.0.1]) by theinternet.com.au (8.12.9/8.12.9) with ESMTP id hB64MmtN003709; Sat, 6 Dec 2003 15:22:48 +1100 (EST) (envelope-from akm@theinternet.com.au) Received: (from akm@localhost) by theinternet.com.au (8.12.9/8.12.9/Submit) id hB64Mmso003708; Sat, 6 Dec 2003 15:22:48 +1100 (EST) Date: Sat, 6 Dec 2003 15:22:48 +1100 From: Andrew Kenneth Milton To: Steve Roome Message-ID: <20031206042248.GA1375@zeus.theinternet.com.au> References: <20031205202852.2576e196.espen@teleport.ch> <20031206031020.GC534@dylan.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031206031020.GC534@dylan.home> User-Agent: Mutt/1.4.1i cc: Espen Jervidalo cc: multimedia@freebsd.org Subject: Re: mplayer -tv with bsdbt848 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2003 04:23:00 -0000 +-------[ Steve Roome ]---------------------- | | I found mplayer does seem to be so slow with full size PAL that I will It's got some odd syncing code in it that basically sleeps for 1 second waiting for frames. I remember altering this code at some point to remove the video syncing for frames and it worked great for full-screen PAL. I hacked up a pretty bad vesa driver for it too, so it would work on the console. At some point I had a VIDIX compat card and vidix worked with it as well. Even w/o VIDIX if you remove the sync code the TV viewing is smooth at full-resolution PAL. -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | M:+61 416 022 411 | ACN: 082 081 472 ABN: 83 082 081 472 |akm@theinternet.com.au| Carpe Daemon From owner-freebsd-multimedia@FreeBSD.ORG Sat Dec 6 00:03:39 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 75FA916A4CE for ; Sat, 6 Dec 2003 00:03:39 -0800 (PST) Received: from smtp6.wanadoo.nl (smtp6.wanadoo.nl [194.134.35.177]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6984E43FA3 for ; Sat, 6 Dec 2003 00:03:38 -0800 (PST) (envelope-from steve@sohara.org) Received: from ams-gw.sohara.org (p0731.nas4-asd6.dial.wanadoo.nl [62.234.222.223]) by smtp6.wanadoo.nl (Postfix) with SMTP id D2AD97859D; Sat, 6 Dec 2003 09:03:35 +0100 (CET) Date: Sat, 6 Dec 2003 09:03:30 +0100 From: Steve O'Hara-Smith To: Espen Jervidalo Message-Id: <20031206090330.2cacaaae.steve@sohara.org> In-Reply-To: <20031205202852.2576e196.espen@teleport.ch> References: <20031205202852.2576e196.espen@teleport.ch> X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i386-portbld-freebsd4.9) X-Face: %]+HVL}K`P8>+8ZcY-WGHP6j@&mxMo9JH6_WdgIgUGH)JX/usO0%jy7T~IVgqjumD^OBqX,Kv^-GM6mlw(fI^$"QRKyZ$?xx/ Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: multimedia@freebsd.org Subject: Re: mplayer -tv with bsdbt848 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2003 08:03:39 -0000 On Fri, 5 Dec 2003 20:28:52 +0100 Espen Jervidalo wrote: EJ> hi list, EJ> EJ> i have been trying to get mplayer working with my Hauppauge WinTV card FreeBSD mplayer TV playback has been broken since 0.90. EJ> sound works, but the picture hangs and looks odd (some green and blue EJ> mixed up stuff), still i'm able to recognize the mtv logo f.e. i tried Yep just like that. I've been using 0.90 for watching TV. -- C:>WIN | Directable Mirrors The computer obeys and wins. |A Better Way To Focus The Sun You lose and Bill collects. | licenses available - see: | http://www.sohara.org/ From owner-freebsd-multimedia@FreeBSD.ORG Sat Dec 6 00:03:48 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D48E016A4CE; Sat, 6 Dec 2003 00:03:48 -0800 (PST) Received: from smtp6.wanadoo.nl (smtp6.wanadoo.nl [194.134.35.177]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6D3343FD7; Sat, 6 Dec 2003 00:03:47 -0800 (PST) (envelope-from steve@sohara.org) Received: from ams-gw.sohara.org (p0731.nas4-asd6.dial.wanadoo.nl [62.234.222.223]) by smtp6.wanadoo.nl (Postfix) with SMTP id AA71977A64; Sat, 6 Dec 2003 09:03:46 +0100 (CET) Date: Sat, 6 Dec 2003 09:03:46 +0100 From: Steve O'Hara-Smith To: "Thomas E. Zander" Message-Id: <20031206090346.618c7cdb.steve@sohara.org> In-Reply-To: <20031205224823.GB59259@o503.hadiko.de> References: <20031205224823.GB59259@o503.hadiko.de> X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i386-portbld-freebsd4.9) X-Face: %]+HVL}K`P8>+8ZcY-WGHP6j@&mxMo9JH6_WdgIgUGH)JX/usO0%jy7T~IVgqjumD^OBqX,Kv^-GM6mlw(fI^$"QRKyZ$?xx/ Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: ports@freebsd.org cc: espen@teleport.ch cc: multimedia@freebsd.org Subject: Re: Testers needed: mplayer+bt848 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2003 08:03:49 -0000 On Fri, 5 Dec 2003 23:48:23 +0100 "Thomas E. Zander" wrote: TEZ> if you use mplayer with your tv tuner card and you encounter problems TEZ> since mplayer jumped from 0.90 to 0.92, would you please try this TEZ> port TEZ> TEZ> http://www.stud.uni-karlsruhe.de/~uedc/mplayer/mplayer.tar.bz2 TEZ> TEZ> instead of the standard one? It contains a patch by Simun Mikecin TEZ> which could resolve some problems. It still leaves me with a scrambled mess unfortunately. -- C:>WIN | Directable Mirrors The computer obeys and wins. |A Better Way To Focus The Sun You lose and Bill collects. | licenses available - see: | http://www.sohara.org/ From owner-freebsd-multimedia@FreeBSD.ORG Sat Dec 6 09:02:57 2003 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7190016A4CE for ; Sat, 6 Dec 2003 09:02:57 -0800 (PST) Received: from hak.cnd.mcgill.ca (hak.cnd.mcgill.ca [132.216.11.133]) by mx1.FreeBSD.org (Postfix) with ESMTP id 47A5243FBD for ; Sat, 6 Dec 2003 09:02:56 -0800 (PST) (envelope-from mat@hak.cnd.mcgill.ca) Received: from hak.cnd.mcgill.ca (localhost [127.0.0.1]) by hak.cnd.mcgill.ca (8.12.9/8.12.8) with ESMTP id hB6Gxu15095752; Sat, 6 Dec 2003 11:59:56 -0500 (EST) (envelope-from mat@hak.cnd.mcgill.ca) Received: (from mat@localhost) by hak.cnd.mcgill.ca (8.12.9/8.12.8/Submit) id hB6Gxtbo095751; Sat, 6 Dec 2003 11:59:55 -0500 (EST) Date: Sat, 6 Dec 2003 11:59:55 -0500 From: Mathew Kanner To: John Wehle Message-ID: <20031206165955.GA54011@cnd.mcgill.ca> References: <200312050618.hB56IYi00447@jwlab.FEITH.COM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200312050618.hB56IYi00447@jwlab.FEITH.COM> User-Agent: Mutt/1.4.1i Organization: I speak for myself, operating in Montreal, CANADA X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on hak.cnd.mcgill.ca cc: jmg@gate.funkthat.com cc: multimedia@freebsd.org Subject: Re: FreeBSD 4.9 Hauppauge PVR-250 / 350 Driver Patch X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Dec 2003 17:02:57 -0000 On Dec 05, John Wehle wrote: > To use the Hauppauge PVR-250 / 350 on FreeBSD 4.9: > [...] John, Congratulations and thank you for writing and donating this driver. I don't have the hardware to test it but I looked at the code and saw nothing that offended me :) Don't take the deafening silence on the e-mail list as a lack of notice or aprication, it was similar for me when I first released a test driver for midi. What would you like to happen to your driver? I think it should eventually be committed to the tree. Do you have a website to host this? If not, I can provide it. Cheers, --Mat -- It's impossible to awaken a man who is pretending to be asleep. - Navajo saying