From owner-freebsd-multimedia@FreeBSD.ORG Sun Jan 9 20:34:15 2011 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ADF37106564A for ; Sun, 9 Jan 2011 20:34:15 +0000 (UTC) (envelope-from gallatin@gmail.com) Received: from mail-yi0-f54.google.com (mail-yi0-f54.google.com [209.85.218.54]) by mx1.freebsd.org (Postfix) with ESMTP id 661E08FC19 for ; Sun, 9 Jan 2011 20:34:15 +0000 (UTC) Received: by yie19 with SMTP id 19so5526945yie.13 for ; Sun, 09 Jan 2011 12:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ifREZ5I6WB14T9coGcs2fgsWeVxL7FdRjzW6zDxx9kY=; b=FyDMxYLQ1eMKbMWs0XU6GO+Ubq3wwBSBYzuXXvODi1r7uVUcFyb6GQbQentOFpaAge B5Jl16EznnG25eA9o6hTgpFmSl0JG4tHn5rbv5HBfZ7AMX1BcCBOo4z9yA61CMAaaKdE +Hk6H2mog1OJ8giBVNKfAMlJ1S6UOW49lJ5U4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=AECnCTocTPm3koreVifcmRcJeemIi+xm+W/0sHkmEbDEH7Cd59pdZOJhc08h9WygOM DA7Yt2RCU5MFNkvrMkRJ+wOa0xAJGw/ztwNDFrNw426ppxunRYI5O+Xk/cNzqBq8ZGNy T6yWOyhXZtzknKqbEphHIsYqXvvR6ScV4p7no= MIME-Version: 1.0 Received: by 10.100.57.15 with SMTP id f15mr3748886ana.228.1294605253641; Sun, 09 Jan 2011 12:34:13 -0800 (PST) Received: by 10.100.248.15 with HTTP; Sun, 9 Jan 2011 12:34:13 -0800 (PST) In-Reply-To: <201101082130.05180.hselasky@c2i.net> References: <201101082130.05180.hselasky@c2i.net> Date: Sun, 9 Jan 2011 15:34:13 -0500 Message-ID: From: Andrew Gallatin To: Hans Petter Selasky Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-multimedia@freebsd.org Subject: Re: em28xx? X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Jan 2011 20:34:15 -0000 On Sat, Jan 8, 2011 at 3:30 PM, Hans Petter Selasky wrot= e: > On Saturday 08 January 2011 20:49:59 Andrew Gallatin wrote: >> On Sat, Jan 8, 2011 at 2:11 PM, Andrew Gallatin wro= te: >> > (see appended output). =A0Has anybody tried =A0this before? =A0What ar= e the >> > general steps for porting a driver? >> >> So I hacked on it for a while (see attached dirty patch) and I've got > > Try the attached patch. Thanks, but it didn't work. I think that (part) of the problem is that the dev it is using is not the one you're initializing. It is using sc->ui->dev. I tried an analogous patch to initialize that dev, and it got me much, much further along: @@ -403,7 +403,10 @@ return (-ENOMEM); } ui =3D p_dev->bsd_iface_start + i; + ui->dev.driver_static.name =3D "webcamd"; + ui->dev.driver =3D &ui->dev.driver_static; + printf("sc =3D %p\n", sc); sc->udrv =3D udrv; sc->p_dev =3D p_dev; sc->ui =3D ui; The device now attaches the analog part, but I don't have digital yet (which is what I want/need). The problem I have now is that dvb_init() is stuck trying to acquire a mute= x. I don't suppose we have WITNESS for the linux code ;) Drew (gdb) thread apply all bt Thread 8 (Thread 801008200 (LWP 100261)): #0 0x0000000800cebcfc in poll () from /lib/libc.so.7 #1 0x0000000800a307fe in poll () from /lib/libthr.so.3 #2 0x000000080081d63d in libusb20_dev_wait_process () from /usr/lib/libusb= .so.2 #3 0x0000000000407a66 in usb_exec (arg=3DVariable "arg" is not available. ) at /usr/home/gallatin/tmp/webcamd-0.1.18/kernel/linux_usb.c:185 #4 0x0000000800a2e2be in pthread_getprio () from /lib/libthr.so.3 #5 0x0000000000000000 in ?? () Error accessing memory address 0x7fffff3fb000: Bad address. Thread 5 (Thread 801007c00 (LWP 100260)): #0 0x0000000800a34d1c in pthread_kill () from /lib/libthr.so.3 #1 0x0000000800a37103 in pthread_cond_signal () from /lib/libthr.so.3 #2 0x0000000000403716 in __wait_event (q=3D0x7575e0) at /usr/home/gallatin/tmp/webcamd-0.1.18/kernel/linux_thread.c:168 #3 0x00000000004781d5 in pvr2_context_thread_func (foo=3DVariable "foo" is not available. ) at /usr/home/gallatin/tmp/webcamd-0.1.18/v4l-dvb/linux/drivers/media/vide= o/pvrusb2/pvrusb2-context.c:174 #4 0x000000000040387f in kthread_wrapper (arg=3D0x801010060) at /usr/home/gallatin/tmp/webcamd-0.1.18/kernel/linux_thread.c:443 #5 0x0000000800a2e2be in pthread_getprio () from /lib/libthr.so.3 #6 0x0000000000000000 in ?? () Error accessing memory address 0x7fffff7fd000: Bad address. Thread 4 (Thread 801007900 (LWP 100259)): #0 0x0000000800d2ff6c in nanosleep () from /lib/libc.so.7 #1 0x0000000800d2fd25 in usleep () from /lib/libc.so.7 #2 0x0000000800a30268 in usleep () from /lib/libthr.so.3 #3 0x0000000000406212 in timer_exec (arg=3DVariable "arg" is not available= . ) at /usr/home/gallatin/tmp/webcamd-0.1.18/kernel/linux_timer.c:141 #4 0x0000000800a2e2be in pthread_getprio () from /lib/libthr.so.3 #5 0x0000000000000000 in ?? () Error accessing memory address 0x7fffff9fe000: Bad address. Thread 3 (Thread 801007600 (LWP 100258)): #0 0x0000000800a34d1c in pthread_kill () from /lib/libthr.so.3 #1 0x0000000800a37103 in pthread_cond_signal () from /lib/libthr.so.3 #2 0x0000000000405e3c in work_exec (arg=3DVariable "arg" is not available. ) at /usr/home/gallatin/tmp/webcamd-0.1.18/kernel/linux_task.c:111 #3 0x0000000800a2e2be in pthread_getprio () from /lib/libthr.so.3 #4 0x0000000000000000 in ?? () Error accessing memory address 0x7fffffbff000: Bad address. Thread 2 (Thread 801007300 (LWP 100255)): #0 0x0000000800a34d1c in pthread_kill () from /lib/libthr.so.3 #1 0x0000000800a37103 in pthread_cond_signal () from /lib/libthr.so.3 #2 0x0000000000403695 in down (sem=3D0x801208b60) at /usr/home/gallatin/tmp/webcamd-0.1.18/kernel/linux_thread.c:307 #3 0x000000000046ef27 in dvb_init (dev=3D0x801208600) at /usr/home/gallatin/tmp/webcamd-0.1.18/v4l-dvb/linux/drivers/media/video/em2= 8xx/em28xx-dvb.c:502 #4 0x000000000046e963 in em28xx_init_extension (dev=3D0x801208600) at /usr/home/gallatin/tmp/webcamd-0.1.18/v4l-dvb/linux/drivers/media/video/em2= 8xx/em28xx-core.c:1230 #5 0x000000000046ca77 in em28xx_usb_probe (interface=3D0x8011c54b0, id=3D0x6d4488) at /usr/home/gallatin/tmp/webcamd-0.1.18/v4l-dvb/linux/drivers/media/video/em2= 8xx/em28xx-cards.c:2979 #6 0x000000000040853c in usb_linux_probe_p (p_bus=3D0x758e10, p_addr=3D0x758e14, p_index=3D0x758e18) at /usr/home/gallatin/tmp/webcamd-0.1.18/kernel/linux_usb.c:418 #7 0x00000000004f056f in main (argc=3D-5712, argv=3D0x7fffffffead0) at webcamd.c:482 (gdb) frame 3 #3 0x000000000046ef27 in dvb_init (dev=3D0x801208600) at /usr/home/gallatin/tmp/webcamd-0.1.18/v4l-dvb/linux/drivers/media/video/em2= 8xx/em28xx-dvb.c:502 502 mutex_lock(&dev->lock); (gdb) p dev $5 =3D (struct em28xx *) 0x801208600 (gdb) p *dev $6 =3D {name =3D "em28xx #0", '\0' , model =3D 76, devno = =3D 0, chip_id =3D CHIP_ID_EM2870, v4l2_dev =3D {dev =3D 0x8011c54b0, subdevs = =3D {next =3D 0x801208638, prev =3D 0x801208638}, lock =3D , name =3D "webcamd ", '\0' , notify =3D 0}, board =3D {name =3D 0x5890c8 "KWorld PlusTV 340U or UB435-Q (ATSC)", vchannels =3D 0, tuner_type =3D 4, tuner_addr =3D 0, tda9887_conf =3D 0, dvb_gpio =3D 0x6d49f0, suspend_gpio =3D 0x0, tuner_gpio =3D 0x6d4580, mute_gpio =3D 0x0, is_em2800 =3D 0, has_msp34xx =3D 0, mts_firmware =3D 0, max_range_640_480 =3D 0, has_dvb =3D 1, has_snapshot_button =3D 0, is_webcam =3D 0, valid =3D 0, has_ir_i2c =3D 0, xclk =3D 39 '\'', i2c_speed= =3D 64 '@', radio_addr =3D 0 '\0', tvaudio_addr =3D 0, decoder =3D EM28XX_NODECODER, adecoder =3D EM28XX_NOADECODER, input =3D {{type =3D 0, vmux =3D 0, amux =3D EM28XX_AMUX_VIDEO, aout =3D EM28XX_AOUT_PCM_MIC_PCM, gpio =3D 0x0}, {type =3D 0, vmux =3D 0, amux =3D EM28XX_AMUX_VIDEO, aout =3D EM28XX_AOUT_PCM_MIC_PCM, gpio =3D 0x0}, {type =3D 0, vmux =3D 0, amux =3D EM28XX_AMUX_VIDEO, aout =3D EM28XX_AOUT_PCM_MIC_PCM, gpio =3D 0x0}, {type =3D 0, vmux =3D 0, amux =3D EM28XX_AMUX_VIDEO, aout =3D EM28XX_AOUT_PCM_MIC_PCM, gpio =3D 0x0}}, radio =3D {type =3D 0, vmux =3D 0, amux =3D EM28XX_AMUX_VIDEO, aout =3D EM28XX_AOUT_PCM_MIC_PCM, gpio =3D 0x0}, ir_codes =3D 0x0}, em28xx_sensor =3D EM28XX_NOSENSOR, sensor_xres =3D 0, sensor_yres =3D 0, sensor_xtal =3D 0, progressive =3D 0, vinmode =3D 16, vinctl =3D 17, has_audio_class =3D 0, has_alsa_audio =3D 0, format =3D 0x6d4ca0, ir =3D 0x0, wait_after_write =3D 0, devlist =3D {next =3D 0x6d4a90, prev =3D 0x6d4a90}, i2s_speed =3D 0, audio_mode =3D { ac97 =3D EM28XX_NO_AC97, ac97_feat =3D 0, ac97_vendor_id =3D 0, has_audio =3D 0, i2s_3rates =3D 0, i2s_5rates =3D 0}, tuner_type =3D 4, tuner_addr =3D 0, tda9887_conf =3D 0, i2c_adap =3D { owner =3D 0x0, id =3D 65567, class =3D 0, algo =3D 0x6d4c60, algo_data = =3D 0x801208600, level =3D 0 '\0', bus_lock =3D {sem =3D {value =3D 1}}, timeou= t =3D 1000, retries =3D 0, dev =3D {minor =3D 0, busnum =3D 0, kobj =3D , refcount =3D {refcount =3D {counter =3D 1}}, release =3D 0, driver =3D 0x0, parent =3D 0x8011c4b00, driver_data =3D 0x801208630, fops =3D 0x0, cdev =3D 0x0, class =3D 0x0, driver_static =3D {name =3D 0x0, owner =3D 0x0}, devt = =3D 0, name =3D "i2c-129", '\0' , bus_name =3D '\0' , bus_id =3D '\0' }, nr =3D 129, name =3D "em28xx #0"= , '\0' , dev_released =3D {done =3D 0, wait =3D {sleep_ref = =3D 0, sleep_count =3D 0}}}, i2c_client =3D { flags =3D 0, addr =3D 80, name =3D "em28xx internal\000\000\000\000", adapter =3D 0x8012087a8, driver =3D 0x0, dev =3D {minor =3D 0, busnum =3D 0= , kobj =3D , refcount =3D { refcount =3D {counter =3D 0}}, release =3D 0, driver =3D 0x0, paren= t =3D 0x0, driver_data =3D 0x0, fops =3D 0x0, cdev =3D 0x0, class =3D 0x0, driver_static =3D {name =3D 0x0, owner =3D 0x0}, devt =3D 0, name =3D '\0' , bus_name =3D '\0' , bus_id =3D '\0' }, irq =3D 0, detected =3D {next =3D 0x0, prev =3D 0x0}}, users =3D 0, vdev =3D 0x80124a180, norm =3D 255, ctl_freq =3D 0, ctl_input =3D 0, ctl_ainput =3D 0, ctl_aoutput =3D 1, mute =3D 1, volume =3D 31, width =3D 7= 20, height =3D 576, hscale =3D 0, vscale =3D 0, interlaced =3D 1, video_bytesread =3D 0, hash =3D 680043282, i2c_hash =3D= 0, adev =3D {name =3D '\0' , transfer_buffer =3D {0x0, 0x0, 0x0, 0x0, 0x0}, urb =3D {0x0, 0x0, 0x0, 0x0, 0x0}, udev =3D 0x0, capture_transfer_done =3D 0, capture_pcm_substream =3D 0x0, hwptr_done_capture =3D 0, sndcard =3D 0x0, users =3D 0, capture_stream =3D STREAM_OFF, slock =3D }, state =3D 0, io =3D IO_NONE, capture_type =3D 0, vbi_read =3D 0, cur_field =3D 0 '\0', vbi_width =3D 720, vbi_height = =3D 18, request_module_wk =3D {entry =3D { tqe_next =3D 0x0, tqe_prev =3D 0x0}, func =3D 0}, lock =3D {sem =3D {= value =3D 0}}, ctrl_urb_lock =3D {sem =3D {value =3D 1}}, inqueue =3D {next =3D 0= x0, prev =3D 0x0}, outqueue =3D {next =3D 0x0, prev =3D 0x0}, open =3D {sleep_ref =3D 0, sleep_count =3D 0}, wait_fram= e =3D {sleep_ref =3D 0, sleep_count =3D 0}, wait_stream =3D {sleep_ref =3D 0, sleep_count =3D 0}, vbi_dev =3D 0x0, radio_dev =3D 0x0, resources =3D 0, eedata =3D "\032=EBg\225\200\033@=A3=C0\023k\020j\"\000\000\000\000\004W\= 000\r\000\000\000\000\000\000\000\000\000\000D\000\000\000=F0\020\001\000\0= 00\000\000\000[\034=C0\000\000\000 @ \200\002 \001\001", '\0' , "\"\003U\000S\000B\000 \0002\0008\0007\0000\000 \000D\000e\000v\000i\000c\000e", '\0' , vidq =3D {active =3D {next =3D 0x801208cb8, prev =3D 0x801208cb8}, queued =3D {next =3D 0x801208cc8, prev =3D 0x801208cc8}, wq =3D {sleep_ref =3D 0, sleep_count =3D 0}, pos =3D 0}, vbiq= =3D {active =3D {next =3D 0x801208ce8, prev =3D 0x801208ce8}, queued =3D {next =3D 0x801208cf8, prev =3D 0x801208cf8}, wq =3D {sleep_ref =3D 0, sleep_count =3D 0}, pos =3D 0}, isoc_ctl =3D {max_pkt_size =3D 0, num_bufs =3D 0, urb =3D 0x0, transfer_buffer =3D 0x0, cmd =3D 0 '\0', pos =3D 0, size =3D 0, pktsize= =3D 0, field =3D 0, tmp_buf =3D 0, tmp_buf_len =3D 0, vid_buf =3D 0x0, vbi_buf = =3D 0x0, nfields =3D 0, isoc_copy =3D 0}, slock =3D , udev =3D 0x8011c4b00, alt =3D 6, max_pkt_siz= e =3D 2892, num_alt =3D 8, alt_max_pkt_size =3D 0x801164b00, urb =3D {0x0, 0x= 0, 0x0, 0x0, 0x0}, transfer_buffer =3D {0x0, 0x0, 0x0, 0x0, 0x0}, urb_buf =3D '\0' , em28xx_write_regs =3D 0x46d4c0 , em28xx_read_reg =3D 0x46d960 , em28xx_read_reg_req_len =3D 0x46d740 , em28xx_write_regs_req =3D 0x46d320 , em28xx_read_reg_req =3D 0x46d930 , mode =3D EM28XX_SUSPEND, reg_gpo_num =3D 4, reg_gpio_num =3D 8, reg_gpo = =3D 0 '\0', reg_gpio =3D 16 '\020', snapshot_button_path =3D '\0' , sbutton_input_dev =3D 0x0, sbutton_query_work =3D {work =3D {entry =3D {tqe_next =3D 0x0, tqe_prev = =3D 0x0}, func =3D 0}, timer =3D {entry =3D {tqe_next =3D 0x0, tqe_prev =3D 0x0= }, function =3D 0, expires =3D 0, data =3D 0}}, dvb =3D 0x80101f700} (gdb) p dev->lock $7 =3D {sem =3D {value =3D 0}} Thanks, Drew