bktr and GPIO

John-Mark Gurney gurney_j at resnet.uoregon.edu
Fri Oct 26 10:57:10 PDT 2007


Achilleas Mantzios wrote this message on Fri, Oct 26, 2007 at 18:27 +0300:
> ???????? ?????????????????? 26 ?????????????????? 2007 16:59, ??/?? Mark Tinguely ????????????:
> > (deleted information. He is interested in getting the Zoneminder bktr(8)
> > based relays to work).
> >
> > >  I have some contact with the person who manufactures the cards and
> > > writes the linux drivers, and he asked me if FreeBSD has access to bt878
> > > GPIO, and said that it would be easy if so.
> >
> > You will need to know what values need to be writen to which register to
> > enable the particular relay. In the kernel driver source program, add
> > a new ioctl() so that you can enable this feature from the user program.
> 
> According to Vassili Leonov of LML,
> =====================================================
> In relation to bits assignments on LMLBT4M and LMLBT44 cards:
> 
> /* to allow access to GPIO bits for sensors input and
>    alarms output
> 
>    GPIObit    | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
>    assignment | TI | O3|INx| O2| O1|IN4|IN3|IN2|IN1|   |   |
> 
>    IN - sensor inputs, INx - sensor inputs and TI XORed together
>    O1,O2,O3 - alarm outputs (relays)
> 
>    GPIO bits should be enabled for outpus as follows:
> 
>    OUT ENABLE   1    1   0  . 1  1   0   0 . 0   0   0    0   = 0x6C0
> 
> */
> 
> So the words are 11 bits long.
> 
> >
> > The command inside the new ioctl() will probably look roughly like:
> >
> > #ifdef OPTIONAL_READ_OLD
> > 	/* optionally may need to preserve some other settings */
> > set = (IN#(bktr, BKTR_GPIO_@@@@) & ~mask) | set;
> > #endif
> > OUT#(bktr, BKTR_GPIO_@@@@, set);	/* turn on relay "value" */
> >
> >  where
> >      mask   optional turn off bits
> >       set   enable bits
> > 	 #  is the size (B)yte, (W)ord, (L)ong
> >        @@@@ is the register location (you probably will have to add a
> > 	    define for this location into the header file).
> 
> Is 
> 
> #define BKTR_GPIO_DMA_CTL               0x10C
> #define BKTR_GPIO_OUT_EN                0x118
> #define BKTR_GPIO_REG_INP               0x11C
> #define BKTR_GPIO_DATA                  0x200
> 
> in /usr/src/sys/dev/bktr/bktr_reg.h any relevant to the above?

No, that is internal to the driver...

> What to they represent?
> Why i was able to call ioctl BT848_GPIO_* on /dev/tuner0 but 
> not /dev/bktr0?

I'm not sure why..  It was the decision made by whom ever wrote
the code.. I do agree that it's a bit weird, but usually the gpio
pins are used to reset the tuner, so they figured that it was easier
for the tuner driver (which don't really exist except for in the kernel)
to have access to them than the video capture device...

> A little enlightment would be great!

You want to look in /usr/include/dev/bktr/ioctl_bt848.h at:
#define BT848_GPIO_SET_EN      _IOW('x', 72, int)      /* set gpio_out_en */
#define BT848_GPIO_GET_EN      _IOR('x', 73, int)      /* get gpio_out_en */
#define BT848_GPIO_SET_DATA    _IOW('x', 74, int)      /* set gpio_data */
#define BT848_GPIO_GET_DATA    _IOR('x', 75, int)      /* get gpio_data */

SET_EN sets the input/output enable bits, GET_EN gets the current bits..
Then you can use SET_DATA/GET_DATA to change/read the data on the bits...

If you look at:
http://perforce.freebsd.org/fileViewer.cgi?FSPC=//depot/user/jmg/bktrau/capture/main.c&REV=27

You'll see how I manipulate the bits to reset the tuner...

Good luck!

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-multimedia mailing list