From owner-freebsd-drivers@freebsd.org Fri Oct 27 03:18:09 2017 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44662E5A223 for ; Fri, 27 Oct 2017 03:18:09 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: from mail-qk0-x22c.google.com (mail-qk0-x22c.google.com [IPv6:2607:f8b0:400d:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BABC574488 for ; Fri, 27 Oct 2017 03:18:08 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: by mail-qk0-x22c.google.com with SMTP id k123so6854444qke.3 for ; Thu, 26 Oct 2017 20:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Vo2PErhryFTQo/jjEi0RoR7igmC316RcoNp62hmkhNk=; b=Sl01Ep+tiZHizDggAam/BkFd+5S4VqousKoOWrvUtlVeKK+xxmHY3Vf3qB8KdyF7Xe 9hxJgsdYiAiz0EDcjdgpb4NHdj/gyAZIfed+rJP323vcRcFIQ+Aobpzo82uzpkQWWsYW 7ysrDJVEkZYApWuVFwII7F1MzYcIzHMQmiYtLZp3DM9kVj18zl0cE2BClwGcSptb+lQN hA+mzCQeYS4/dwWxUUnv5r/B0MgECAFsKDF6LQqtArSvgwPppSxrWJJTl2mFn/QxHuxh ek0jzkeh/EcBHoEJVLDwFFEe73iJzW2vJo/viScr2nIu2o1KegWfJhODOXMyGoE52W6M H2NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Vo2PErhryFTQo/jjEi0RoR7igmC316RcoNp62hmkhNk=; b=YaouZFIJkI+1BcCZmw0uF/m23UkiOTos9D1UyrdoII8uWAStbotAeaS9HLuaDYoKsF xfyEMAIr74qbH7PolcnTs7h0diRvl725GuD7dDbthQiXljcsAOlez+QpsGWyK6k7NiE2 LLCXlWvoffRzZCKUDfX3oSRhovuO0SZR9utUyxqf4Z+cE7hGbDhAQY3Tji7IFv5zadN7 kDcFAG5VKBH9y/+SZQ8kZ+9qCvwTGIMBi1RgnP2qLZCC1eZPM/HKj+mw/AszrzwZsTdG rqSqJAhjw2du3qaqzZddbzru09XDFVCwImYt4vjv7nMco34InR4Ad60CNVp4d8pXgVul +PjQ== X-Gm-Message-State: AMCzsaW5tKGbkSML3yUMHFEqNcniZLY7cwF7ATDtqwCSQ8VjDD+3CbX4 29kkHLroXAfRicMPBSi6cBUEhaJz X-Google-Smtp-Source: ABhQp+SeJvxkmFwi4H9aaDbIXLuXA2Ta9PjsjV5vB5pHKprkBG7G2UgQirGtey49pfa1ImDDiUevpw== X-Received: by 10.55.160.18 with SMTP id j18mr11444520qke.327.1509074286592; Thu, 26 Oct 2017 20:18:06 -0700 (PDT) Received: from pc.farhan.codes ([2001:470:8:209::dead:c0de]) by smtp.gmail.com with ESMTPSA id t84sm4388943qki.13.2017.10.26.20.18.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 20:18:05 -0700 (PDT) Subject: Re: Getting into USB drivers To: blubee blubeeme , freebsd-drivers@freebsd.org References: From: Farhan Khan Message-ID: <5bd8a40a-2795-6a1a-d8e7-2fc603fdfc2a@gmail.com> Date: Thu, 26 Oct 2017 23:18:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 03:18:09 -0000 Hi! I am working with on a PCIe driver, but I've done a bit of reading on USB drivers on Linux, and its probably not too different from BSD. Chapter 9 of the Architecture Handbook is a good start. The usb(4) man page is pretty solid, it gets into the data structures and API calls. In my opinion though, man pages don't make any sense unless you already have a sense of what you are doing, so I would also read a few sample drivers that are out there. There's an excellent book called "FreeBSD Device Drivers: A Guide for the Intrepid" that helps to bring everything together. It has sample drivers and builds you into things slowly. Though a different OS, the Linux documentation is pretty good. One article that helped me was this: http://matthias.vallentin.net/blog/2007/04/writing-a-linux-kernel-driver-for-an-unknown-usb-device/ and Linux's drivers/usb/usb-skeleton.c sample driver. That looks like a laptop camera, right? I think I used to have it. Would be great if you got it over! On 10/26/2017 10:18 PM, blubee blubeeme wrote: > I have a USB webcam that I would like to get into writing drivers for as a > practical introduction to writing drivers for FreeBSD. I am not sure if > this one already has a driver but here's the usb dump of the device. > > Anyone here willing to give me some pointers on writing drivers? > > > me@blubee:~ % sudo usbconfig -d 0.5 dump_all_config_desc > Password: > ugen0.5: at usbus0, cfg=0 md=HOST > spd=HIGH (480Mbps) pwr=ON (500mA) > > > Configuration index 0 > > bLength = 0x0009 > bDescriptorType = 0x0002 > wTotalLength = 0x03a9 > bNumInterfaces = 0x0002 > bConfigurationValue = 0x0001 > iConfiguration = 0x0000 > bmAttributes = 0x0080 > bMaxPower = 0x00fa > > Additional Descriptor > > bLength = 0x08 > bDescriptorType = 0x0b > bDescriptorSubType = 0x00 > RAW dump: > 0x00 | 0x08, 0x0b, 0x00, 0x02, 0x0e, 0x03, 0x00, 0x04 > > > Interface 0 > bLength = 0x0009 > bDescriptorType = 0x0004 > bInterfaceNumber = 0x0000 > bAlternateSetting = 0x0000 > bNumEndpoints = 0x0001 > bInterfaceClass = 0x000e