Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1630041 > unrolled thread
| Started by | Pavel Machek <pavel@ucw.cz> |
|---|---|
| First post | 2017-04-24 23:30 +0200 |
| Last post | 2017-04-29 11:20 +0200 |
| Articles | 20 on this page of 23 — 6 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: support autofocus / autogain in libv4l2 Pavel Machek <pavel@ucw.cz> - 2017-04-24 23:30 +0200
Re: support autofocus / autogain in libv4l2 Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-04-25 03:50 +0200
Re: support autofocus / autogain in libv4l2 Pavel Machek <pavel@ucw.cz> - 2017-04-25 10:10 +0200
Re: support autofocus / autogain in libv4l2 Pali Rohár <pali.rohar@gmail.com> - 2017-04-25 10:20 +0200
Re: support autofocus / autogain in libv4l2 Pavel Machek <pavel@ucw.cz> - 2017-04-25 13:30 +0200
Re: support autofocus / autogain in libv4l2 Pali Rohár <pali.rohar@gmail.com> - 2017-04-25 13:40 +0200
Re: support autofocus / autogain in libv4l2 Pavel Machek <pavel@ucw.cz> - 2017-04-25 14:30 +0200
Re: support autofocus / autogain in libv4l2 Pali Rohár <pali.rohar@gmail.com> - 2017-04-25 15:00 +0200
Re: support autofocus / autogain in libv4l2 Nicolas Dufresne <nicolas@ndufresne.ca> - 2017-04-25 19:00 +0200
Re: support autofocus / autogain in libv4l2 Nicolas Dufresne <nicolas@ndufresne.ca> - 2017-04-25 19:00 +0200
Re: support autofocus / autogain in libv4l2 Nicolas Dufresne <nicolas@ndufresne.ca> - 2017-04-25 19:00 +0200
Re: support autofocus / autogain in libv4l2 Pavel Machek <pavel@ucw.cz> - 2017-04-26 13:00 +0200
[patch] propagating controls in libv4l2 was Re: support autofocus / autogain in libv4l2 Pavel Machek <pavel@ucw.cz> - 2017-04-26 13:00 +0200
Re: [patch] propagating controls in libv4l2 was Re: support autofocus / autogain in libv4l2 Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-04-26 13:20 +0200
[patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) Pavel Machek <pavel@ucw.cz> - 2017-04-26 15:30 +0200
Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2017-04-26 17:50 +0200
Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) Pavel Machek <pavel@ucw.cz> - 2017-04-27 01:00 +0200
Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> - 2017-04-27 08:00 +0200
Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-05-03 21:10 +0200
Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) Pavel Machek <pavel@ucw.cz> - 2017-05-03 22:00 +0200
Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) Pavel Machek <pavel@ucw.cz> - 2017-05-01 00:50 +0200
Re: [patch] propagating controls in libv4l2 was Re: support autofocus / autogain in libv4l2 Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-04-26 13:30 +0200
Re: [patch] propagating controls in libv4l2 was Re: support autofocus / autogain in libv4l2 Pavel Machek <pavel@ucw.cz> - 2017-04-29 11:20 +0200
Page 1 of 2 [1] 2 Next page →
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-24 23:30 +0200 |
| Subject | Re: support autofocus / autogain in libv4l2 |
| Message-ID | <tzTIt-3OV-13@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
Hi!
> > For focus to be useful, we need autofocus implmented
> > somewhere. Unfortunately, v4l framework does not seem to provide good
> > place where to put autofocus. I believe, long-term, we'll need some
> > kind of "video server" providing this kind of services.
> >
> > Anyway, we probably don't want autofocus in kernel (even through some
> > cameras do it in hardware), and we probably don't want autofocus in
> > each and every user application.
> >
> > So what remains is libv4l2.
>
> IMO, the best place for autofocus is at libv4l2. Putting it on a
> separate "video server" application looks really weird for me.
Well... let me see. libraries are quite limited -- it is hard to open
files, or use threads/have custom main loop. It may be useful to
switch resolutions -- do autofocus/autogain at lower resolution, then
switch to high one for taking picture. It would be good to have that
in "system" code, but I'm not at all sure libv4l2 design will allow
that.
It would be good if application could say "render live camera into
this window" and only care about user interface, then say "give me a
high resolution jpeg". But that would require main loop in the
library...
It would be nice if more than one application could be accessing the
camera at the same time... (I.e. something graphical running preview
then using command line tool to grab a picture.) This one is
definitely not solveable inside a library...
> Btw, libv4l2 already has some autotools for auto gain and auto
> white balance. See the implementation under:
> lib/libv4lconvert/processing
>
> The libv4l internal controls can be seen at:
> lib/libv4lconvert/control/libv4lcontrol.h
>
> The ones implemented by the processing part of the library are:
Thanks for pointer, will take a look.
> > Now, this is in no way clean or complete,
> > and functionality provided by sdl.c and asciicam.c probably _should_
> > be in application, but... I'd like to get the code out there.
> >
> > Oh and yes, I've canibalized decode_tm6000.c application instead of
> > introducing my own. Autotools scare me, sorry.
>
> Why replace decode_tm6000.c by something else? If you want to add another
> test application, just place it on a new file.
Scary scary scary autotools ;-). Yes, I did rather lot of hacks, as
you noted below. I do development on n900, so not everything is easy.
> I added a few notes together with the code, pointing the main things
> I think it require changes, in order for me to do a better review
> at the code. I didn't test nor tried to check the algorithms inside,
> as the code, on its current state, requires rework and code cleanup.
Thanks, I'll take a look.
> Please don't add a new application under lib/. It is fine if you want
> some testing application, if the ones there aren't enough, but please
> place it under contrib/test/.
>
> You should likely take a look at v4l2grab first, as it could have
> almost everything you would need.
Will take a look, thanks for pointer.
> IMHO, it would be better to use aalib. Btw, xawtv3 has a code example
> using it, under:
> console/ttv.c
>
> As it already uses libv4l, prhaps you could use it, instead of adding
> a new ascii app.
No need to duplicate it, then. I was trying to quickly test video
works, this was before SDL.
> > +#include "sdl.c"
> > +
> > +static struct sdl sdl;
> > +
> > +int v4l2_get_index(int fd);
> > +void my_main(void);
> > +
>
> The above looks really odd. Why do you want to make libv4l2 dependent
> on sdl?
I don't, but I had some nasty problems with linker; this should really
go into application but it refused to link. Scary libtool.
> > +static void v4l2_histogram(unsigned char *buf, int cdf[], struct v4l2_format *fmt)
> > +{
> > + for (int y = 0; y < fmt->fmt.pix.height; y+=19)
> > + for (int x = 0; x < fmt->fmt.pix.width; x+=19) {
> > + pixel p = buf_pixel(fmt, buf, x, y);
> > +
> > + int b;
> > + /* HACK: we divide green by 2 to have nice picture, undo it here. */
> > + b = p.r + 2*p.g + p.b;
> > + b = (b * BUCKETS)/(256);
> > + cdf[b]++;
> > + }
> > +}
> > +
> > +static long v4l2_sharpness(unsigned char *buf, struct v4l2_format *fmt)
> > +{
> > + int h = fmt->fmt.pix.height;
> > + int w = fmt->fmt.pix.width;
> > + long r = 0;
> > +
> > + for (int y = h/3; y < h-h/3; y+=h/9)
> > + for (int x = w/3; x < w-w/3; x++) {
> > + pixel p1 = buf_pixel(fmt, buf, x, y);
> > + pixel p2 = buf_pixel(fmt, buf, x+2, y);
> > +
> > + int b1, b2;
> > + /* HACK: we divide green by 2 to have nice picture, undo it here. */
> > + b1 = p1.r + 2*p1.g + p1.b;
> > + b2 = p2.r + 2*p2.g + p2.b;
> > +
> > + int v;
> > + v = (b1-b2)*(b1-b2);
> > + if (v > 36)
> > + r+=v;
> > + }
> > +
> > + return r;
> > +}
>
> IMO, the above belongs to a separate processing module under
> lib/libv4lconvert/processing/
I guess so.
> > +
> > +int v4l2_set_exposure(int fd, int exposure)
> > +{
> > + int index = v4l2_get_index(fd);
> > +
> > + if (index == -1 || devices[index].convert == NULL) {
> > + V4L2_LOG_ERR("v4l2_set_exposure called with invalid fd: %d\n", fd);
> > + errno = EBADF;
> > + return -1;
> > + }
> > +
> > + struct v4l2_control ctrl;
> > + ctrl.id = V4L2_CID_EXPOSURE;
> > + ctrl.value = exposure;
> > + if (ioctl(devices[index].subdev_fds[0], VIDIOC_S_CTRL, &ctrl) < 0) {
> > + printf("Could not set exposure\n");
> > + }
> > + return 0;
> > +}
>
> Shouldn't it be together with lib/libv4lconvert/processing/autogain.c,
> perhaps as an alternative implementation, if what's there is not
> enough?
I'll take a look, thanks.
> > @@ -823,6 +1246,10 @@ int v4l2_close(int fd)
> > {
> > int index, result;
> >
> > + if (fd == -2) {
> > + my_main();
> > + }
> > +
>
> That looks a hack!
That is _the_ hack ;-). Yes, agreed, need to look at
processing/. .. when I get time.
> > +#include <SDL2/SDL.h>
> > +#include <SDL2/SDL_image.h>
>
> If you're adding a SDL-specific application, you'll need to add the
> needed autoconf bits to detect if SDL devel package is installed,
> auto-disabling it if not.
>
> Yet, I don't think that SDL should be part of the library, but,
> instead, part of some application.
Agreed. libtool prevented me from doing the right thing.
> > index 4bffbdd..fda7e3b 100644
> > --- a/utils/decode_tm6000/decode_tm6000.c
> > +++ b/utils/decode_tm6000/decode_tm6000.c
>
> Everything below it is completely wrong!
And most of the stuff above is, too :-). I wanted to get the code out
in case I won't have time...
Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [next] | [standalone]
| From | Mauro Carvalho Chehab <mchehab@s-opensource.com> |
|---|---|
| Date | 2017-04-25 03:50 +0200 |
| Message-ID | <tzXM5-6p1-1@gated-at.bofh.it> |
| In reply to | #1630041 |
Em Mon, 24 Apr 2017 23:29:14 +0200 Pavel Machek <pavel@ucw.cz> escreveu: > Hi! > > > > For focus to be useful, we need autofocus implmented > > > somewhere. Unfortunately, v4l framework does not seem to provide good > > > place where to put autofocus. I believe, long-term, we'll need some > > > kind of "video server" providing this kind of services. > > > > > > Anyway, we probably don't want autofocus in kernel (even through some > > > cameras do it in hardware), and we probably don't want autofocus in > > > each and every user application. > > > > > > So what remains is libv4l2. > > > > IMO, the best place for autofocus is at libv4l2. Putting it on a > > separate "video server" application looks really weird for me. > > Well... let me see. libraries are quite limited -- it is hard to open > files, or use threads/have custom main loop. It may be useful to > switch resolutions -- do autofocus/autogain at lower resolution, then > switch to high one for taking picture. It would be good to have that > in "system" code, but I'm not at all sure libv4l2 design will allow > that. I don't see why it would be hard to open files or have threads inside a library. There are several libraries that do that already, specially the ones designed to be used on multimidia apps. Resolution switch can indeed be a problem on devices that use MC and subdev API, as a plugin would be required to teach the library about N9 specifics (or the Kernel API should be improved to let a generic application to better detect the hardware capabilities). > It would be good if application could say "render live camera into > this window" and only care about user interface, then say "give me a > high resolution jpeg". But that would require main loop in the > library... Nothing prevents writing an upper layer on the top of libv4l in order to provide such kind of functions. > It would be nice if more than one application could be accessing the > camera at the same time... (I.e. something graphical running preview > then using command line tool to grab a picture.) This one is > definitely not solveable inside a library... Someone once suggested to have something like pulseaudio for V4L. For such usage, a server would be interesting. Yet, I would code it in a way that applications using libv4l will talk with such daemon in a transparent way. > > The above looks really odd. Why do you want to make libv4l2 dependent > > on sdl? > > I don't, but I had some nasty problems with linker; this should really > go into application but it refused to link. Scary libtool. That's weird. > > If you're adding a SDL-specific application, you'll need to add the > > needed autoconf bits to detect if SDL devel package is installed, > > auto-disabling it if not. > > > > Yet, I don't think that SDL should be part of the library, but, > > instead, part of some application. > > Agreed. libtool prevented me from doing the right thing. if you add libSDL detection at configure.ac, you likely won't need to deal with libtool. On a quick look at web, it seems that there's a m4 module that does the right thing, according with: https://wiki.libsdl.org/FAQLinux Thanks, Mauro
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-25 10:10 +0200 |
| Message-ID | <tA3HP-24M-3@gated-at.bofh.it> |
| In reply to | #1630142 |
[Multipart message — attachments visible in raw view] — view raw
Hi! > > > > For focus to be useful, we need autofocus implmented > > > > somewhere. Unfortunately, v4l framework does not seem to provide good > > > > place where to put autofocus. I believe, long-term, we'll need some > > > > kind of "video server" providing this kind of services. > > > > > > > > Anyway, we probably don't want autofocus in kernel (even through some > > > > cameras do it in hardware), and we probably don't want autofocus in > > > > each and every user application. > > > > > > > > So what remains is libv4l2. > > > > > > IMO, the best place for autofocus is at libv4l2. Putting it on a > > > separate "video server" application looks really weird for me. > > > > Well... let me see. libraries are quite limited -- it is hard to open > > files, or use threads/have custom main loop. It may be useful to > > switch resolutions -- do autofocus/autogain at lower resolution, then > > switch to high one for taking picture. It would be good to have that > > in "system" code, but I'm not at all sure libv4l2 design will allow > > that. > > I don't see why it would be hard to open files or have threads inside > a library. There are several libraries that do that already, specially > the ones designed to be used on multimidia apps. Well, fd's are hard, because application can do fork() and now interesting stuff happens. Threads are tricky, because now you have locking etc. libv4l2 is designed to be LD_PRELOADED. That is not really feasible with "complex" library. > > It would be good if application could say "render live camera into > > this window" and only care about user interface, then say "give me a > > high resolution jpeg". But that would require main loop in the > > library... > > Nothing prevents writing an upper layer on the top of libv4l in > order to provide such kind of functions. Agreed. > > It would be nice if more than one application could be accessing the > > camera at the same time... (I.e. something graphical running preview > > then using command line tool to grab a picture.) This one is > > definitely not solveable inside a library... > > Someone once suggested to have something like pulseaudio for V4L. > For such usage, a server would be interesting. Yet, I would code it > in a way that applications using libv4l will talk with such daemon > in a transparent way. Yes, we need something like pulseaudio for V4L. And yes, we should make it transparent for applications using libv4l. Regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Pali Rohár <pali.rohar@gmail.com> |
|---|---|
| Date | 2017-04-25 10:20 +0200 |
| Message-ID | <tA3Rw-28G-15@gated-at.bofh.it> |
| In reply to | #1630267 |
On Tuesday 25 April 2017 10:05:38 Pavel Machek wrote: > > > It would be nice if more than one application could be accessing the > > > camera at the same time... (I.e. something graphical running preview > > > then using command line tool to grab a picture.) This one is > > > definitely not solveable inside a library... > > > > Someone once suggested to have something like pulseaudio for V4L. > > For such usage, a server would be interesting. Yet, I would code it > > in a way that applications using libv4l will talk with such daemon > > in a transparent way. > > Yes, we need something like pulseaudio for V4L. And yes, we should > make it transparent for applications using libv4l. IIRC there is already some effort in writing such "video" server which would support accessing more application into webcam video, like pulseaudio server for accessing more applications to microphone input. -- Pali Rohár pali.rohar@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-25 13:30 +0200 |
| Message-ID | <tA6Po-420-5@gated-at.bofh.it> |
| In reply to | #1630279 |
[Multipart message — attachments visible in raw view] — view raw
Hi! On Tue 2017-04-25 10:08:15, Pali Rohár wrote: > On Tuesday 25 April 2017 10:05:38 Pavel Machek wrote: > > > > It would be nice if more than one application could be accessing the > > > > camera at the same time... (I.e. something graphical running preview > > > > then using command line tool to grab a picture.) This one is > > > > definitely not solveable inside a library... > > > > > > Someone once suggested to have something like pulseaudio for V4L. > > > For such usage, a server would be interesting. Yet, I would code it > > > in a way that applications using libv4l will talk with such daemon > > > in a transparent way. > > > > Yes, we need something like pulseaudio for V4L. And yes, we should > > make it transparent for applications using libv4l. > > IIRC there is already some effort in writing such "video" server which > would support accessing more application into webcam video, like > pulseaudio server for accessing more applications to microphone input. Do you have project name / url / something? Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Pali Rohár <pali.rohar@gmail.com> |
|---|---|
| Date | 2017-04-25 13:40 +0200 |
| Message-ID | <tA6Z4-45M-3@gated-at.bofh.it> |
| In reply to | #1630420 |
On Tuesday 25 April 2017 13:23:30 Pavel Machek wrote: > Hi! > On Tue 2017-04-25 10:08:15, Pali Rohár wrote: > > On Tuesday 25 April 2017 10:05:38 Pavel Machek wrote: > > > > > It would be nice if more than one application could be accessing the > > > > > camera at the same time... (I.e. something graphical running preview > > > > > then using command line tool to grab a picture.) This one is > > > > > definitely not solveable inside a library... > > > > > > > > Someone once suggested to have something like pulseaudio for V4L. > > > > For such usage, a server would be interesting. Yet, I would code it > > > > in a way that applications using libv4l will talk with such daemon > > > > in a transparent way. > > > > > > Yes, we need something like pulseaudio for V4L. And yes, we should > > > make it transparent for applications using libv4l. > > > > IIRC there is already some effort in writing such "video" server which > > would support accessing more application into webcam video, like > > pulseaudio server for accessing more applications to microphone input. > > Do you have project name / url / something? Pinos (renamed from PulseVideo) https://blogs.gnome.org/uraeus/2015/06/30/introducing-pulse-video/ https://cgit.freedesktop.org/~wtay/pinos/ But from git history it looks like it is probably dead now... -- Pali Rohár pali.rohar@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-25 14:30 +0200 |
| Message-ID | <tA7Lr-4EF-11@gated-at.bofh.it> |
| In reply to | #1630425 |
[Multipart message — attachments visible in raw view] — view raw
On Tue 2017-04-25 13:30:09, Pali Rohár wrote: > On Tuesday 25 April 2017 13:23:30 Pavel Machek wrote: > > Hi! > > On Tue 2017-04-25 10:08:15, Pali Rohár wrote: > > > On Tuesday 25 April 2017 10:05:38 Pavel Machek wrote: > > > > > > It would be nice if more than one application could be accessing the > > > > > > camera at the same time... (I.e. something graphical running preview > > > > > > then using command line tool to grab a picture.) This one is > > > > > > definitely not solveable inside a library... > > > > > > > > > > Someone once suggested to have something like pulseaudio for V4L. > > > > > For such usage, a server would be interesting. Yet, I would code it > > > > > in a way that applications using libv4l will talk with such daemon > > > > > in a transparent way. > > > > > > > > Yes, we need something like pulseaudio for V4L. And yes, we should > > > > make it transparent for applications using libv4l. > > > > > > IIRC there is already some effort in writing such "video" server which > > > would support accessing more application into webcam video, like > > > pulseaudio server for accessing more applications to microphone input. > > > > Do you have project name / url / something? > > Pinos (renamed from PulseVideo) > > https://blogs.gnome.org/uraeus/2015/06/30/introducing-pulse-video/ > https://cgit.freedesktop.org/~wtay/pinos/ > > But from git history it looks like it is probably dead now... Actually, last commit is an hour ago on "work" branch. Seems alive to me ;-). Thanks for pointer... Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Pali Rohár <pali.rohar@gmail.com> |
|---|---|
| Date | 2017-04-25 15:00 +0200 |
| Message-ID | <tA8et-4Pu-7@gated-at.bofh.it> |
| In reply to | #1630450 |
On Tuesday 25 April 2017 14:28:20 Pavel Machek wrote: > On Tue 2017-04-25 13:30:09, Pali Rohár wrote: > > On Tuesday 25 April 2017 13:23:30 Pavel Machek wrote: > > > Hi! > > > On Tue 2017-04-25 10:08:15, Pali Rohár wrote: > > > > On Tuesday 25 April 2017 10:05:38 Pavel Machek wrote: > > > > > > > It would be nice if more than one application could be accessing the > > > > > > > camera at the same time... (I.e. something graphical running preview > > > > > > > then using command line tool to grab a picture.) This one is > > > > > > > definitely not solveable inside a library... > > > > > > > > > > > > Someone once suggested to have something like pulseaudio for V4L. > > > > > > For such usage, a server would be interesting. Yet, I would code it > > > > > > in a way that applications using libv4l will talk with such daemon > > > > > > in a transparent way. > > > > > > > > > > Yes, we need something like pulseaudio for V4L. And yes, we should > > > > > make it transparent for applications using libv4l. > > > > > > > > IIRC there is already some effort in writing such "video" server which > > > > would support accessing more application into webcam video, like > > > > pulseaudio server for accessing more applications to microphone input. > > > > > > Do you have project name / url / something? > > > > Pinos (renamed from PulseVideo) > > > > https://blogs.gnome.org/uraeus/2015/06/30/introducing-pulse-video/ > > https://cgit.freedesktop.org/~wtay/pinos/ > > > > But from git history it looks like it is probably dead now... > > Actually, last commit is an hour ago on "work" branch. Seems alive to > me ;-). Great! I just (blindly) looked at master branch and it is old... > Thanks for pointer... > Pavel -- Pali Rohár pali.rohar@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Dufresne <nicolas@ndufresne.ca> |
|---|---|
| Date | 2017-04-25 19:00 +0200 |
| Message-ID | <tAbYK-7eg-23@gated-at.bofh.it> |
| In reply to | #1630425 |
[Multipart message — attachments visible in raw view] — view raw
Le mardi 25 avril 2017 à 13:30 +0200, Pali Rohár a écrit : > Pinos (renamed from PulseVideo) > > https://blogs.gnome.org/uraeus/2015/06/30/introducing-pulse-video/ > https://cgit.freedesktop.org/~wtay/pinos/ > > But from git history it looks like it is probably dead now... This is also incorrect. See "work" branch. It is still a one man show, code being aggressively re-factored. I suspect this will be the case until the "form" is considered acceptable. Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Dufresne <nicolas@ndufresne.ca> |
|---|---|
| Date | 2017-04-25 19:00 +0200 |
| Message-ID | <tAbYL-7eg-27@gated-at.bofh.it> |
| In reply to | #1630279 |
[Multipart message — attachments visible in raw view] — view raw
Le mardi 25 avril 2017 à 10:08 +0200, Pali Rohár a écrit : > On Tuesday 25 April 2017 10:05:38 Pavel Machek wrote: > > > > It would be nice if more than one application could be > > > > accessing the > > > > camera at the same time... (I.e. something graphical running > > > > preview > > > > then using command line tool to grab a picture.) This one is > > > > definitely not solveable inside a library... > > > > > > Someone once suggested to have something like pulseaudio for V4L. > > > For such usage, a server would be interesting. Yet, I would code > > > it > > > in a way that applications using libv4l will talk with such > > > daemon > > > in a transparent way. > > > > Yes, we need something like pulseaudio for V4L. And yes, we should > > make it transparent for applications using libv4l. > > IIRC there is already some effort in writing such "video" server > which > would support accessing more application into webcam video, like > pulseaudio server for accessing more applications to microphone > input. > Because references are nice: https://blogs.gnome.org/uraeus/2015/06/30/introducing-pulse-video/ https://gstconf.ubicast.tv/videos/camera-sharing-and-sandboxing-with-pinos/ And why the internals are not going to be implemented using GStreamer in the end: https://gstconf.ubicast.tv/videos/keep-calm-and-refactor-about-the-essence-of-gstreamer/ regards, Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Nicolas Dufresne <nicolas@ndufresne.ca> |
|---|---|
| Date | 2017-04-25 19:00 +0200 |
| Message-ID | <tAbYL-7eg-31@gated-at.bofh.it> |
| In reply to | #1630267 |
[Multipart message — attachments visible in raw view] — view raw
Le mardi 25 avril 2017 à 10:05 +0200, Pavel Machek a écrit : > Well, fd's are hard, because application can do fork() and now > interesting stuff happens. Threads are tricky, because now you have > locking etc. > > libv4l2 is designed to be LD_PRELOADED. That is not really feasible > with "complex" library. That is incorrect. The library propose an API where you simply replace certain low level calls, like ioctl -> v4l2_ioctl, open -> v4l2_open(). You have to do that explicitly in your existing code. It does not abstract the API itself unlike libdrm. Nicolas
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-26 13:00 +0200 |
| Message-ID | <tAsPU-197-17@gated-at.bofh.it> |
| In reply to | #1630801 |
[Multipart message — attachments visible in raw view] — view raw
On Tue 2017-04-25 12:53:27, Nicolas Dufresne wrote: > Le mardi 25 avril 2017 à 10:05 +0200, Pavel Machek a écrit : > > Well, fd's are hard, because application can do fork() and now > > interesting stuff happens. Threads are tricky, because now you have > > locking etc. > > > > libv4l2 is designed to be LD_PRELOADED. That is not really feasible > > with "complex" library. > > That is incorrect. The library propose an API where you simply replace > certain low level calls, like ioctl -> v4l2_ioctl, open -> v4l2_open(). > You have to do that explicitly in your existing code. It does not > abstract the API itself unlike libdrm. You are right, no LD_PRELOAD. But same API as kernel, which is really limiting -- see my other mail. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-26 13:00 +0200 |
| Subject | [patch] propagating controls in libv4l2 was Re: support autofocus / autogain in libv4l2 |
| Message-ID | <tAsPU-197-21@gated-at.bofh.it> |
| In reply to | #1630142 |
[Multipart message — attachments visible in raw view] — view raw
Hi!
> > > IMO, the best place for autofocus is at libv4l2. Putting it on a
> > > separate "video server" application looks really weird for me.
> >
> > Well... let me see. libraries are quite limited -- it is hard to open
> > files, or use threads/have custom main loop. It may be useful to
> > switch resolutions -- do autofocus/autogain at lower resolution, then
> > switch to high one for taking picture. It would be good to have that
> > in "system" code, but I'm not at all sure libv4l2 design will allow
> > that.
>
> I don't see why it would be hard to open files or have threads inside
> a library. There are several libraries that do that already, specially
> the ones designed to be used on multimidia apps.
Well, This is what the libv4l2 says:
This file implements libv4l2, which offers v4l2_ prefixed versions
of
open/close/etc. The API is 100% the same as directly opening
/dev/videoX
using regular open/close/etc, the big difference is that format
conversion
but if I open additional files in v4l2_open(), API is no longer the
same, as unix open() is defined to open just one file descriptor.
Now. There is autogain support in libv4lconvert, but it expects to use
same fd for camera and for the gain... which does not work with
subdevs.
Of course, opening subdevs by name like this is not really
acceptable. But can you suggest a method that is?
Thanks,
Pavel
commit 4cf9d10ead014c0db25452e4bb9cd144632407c3
Author: Pavel <pavel@ucw.cz>
Date: Wed Apr 26 11:38:04 2017 +0200
Add subdevices.
diff --git a/lib/libv4l2/libv4l2-priv.h b/lib/libv4l2/libv4l2-priv.h
index 343db5e..a6bc48e 100644
--- a/lib/libv4l2/libv4l2-priv.h
+++ b/lib/libv4l2/libv4l2-priv.h
@@ -26,6 +26,7 @@
#include "../libv4lconvert/libv4lsyscall-priv.h"
#define V4L2_MAX_DEVICES 16
+#define V4L2_MAX_SUBDEVS 8
/* Warning when making this larger the frame_queued and frame_mapped members of
the v4l2_dev_info struct can no longer be a bitfield, so the code needs to
be adjusted! */
@@ -104,6 +105,7 @@ struct v4l2_dev_info {
void *plugin_library;
void *dev_ops_priv;
const struct libv4l_dev_ops *dev_ops;
+ int subdev_fds[V4L2_MAX_SUBDEVS];
};
/* From v4l2-plugin.c */
diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
index 0ba0a88..edc9642 100644
--- a/lib/libv4l2/libv4l2.c
+++ b/lib/libv4l2/libv4l2.c
@@ -1,3 +1,4 @@
+/* -*- c-file-style: "linux" -*- */
/*
# (C) 2008 Hans de Goede <hdegoede@redhat.com>
@@ -789,18 +790,25 @@ no_capture:
/* Note we always tell v4lconvert to optimize src fmt selection for
our default fps, the only exception is the app explicitly selecting
- a fram erate using the S_PARM ioctl after a S_FMT */
+ a frame rate using the S_PARM ioctl after a S_FMT */
if (devices[index].convert)
v4lconvert_set_fps(devices[index].convert, V4L2_DEFAULT_FPS);
v4l2_update_fps(index, &parm);
+ devices[index].subdev_fds[0] = SYS_OPEN("/dev/video_sensor", O_RDWR, 0);
+ devices[index].subdev_fds[1] = SYS_OPEN("/dev/video_focus", O_RDWR, 0);
+ devices[index].subdev_fds[2] = -1;
+
+ printf("Sensor: %d, focus: %d\n", devices[index].subdev_fds[0],
+ devices[index].subdev_fds[1]);
+
V4L2_LOG("open: %d\n", fd);
return fd;
}
/* Is this an fd for which we are emulating v4l1 ? */
-static int v4l2_get_index(int fd)
+int v4l2_get_index(int fd)
{
int index;
commit 1d6a9ce121f53e8f2e38549eed597a3c3dea5233
Author: Pavel <pavel@ucw.cz>
Date: Wed Apr 26 12:34:04 2017 +0200
Enable ioctl propagation.
diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
index edc9642..6dab661 100644
--- a/lib/libv4l2/libv4l2.c
+++ b/lib/libv4l2/libv4l2.c
@@ -1064,6 +1064,23 @@ static int v4l2_s_fmt(int index, struct v4l2_format *dest_fmt)
return 0;
}
+static int v4l2_propagate_ioctl(int index, unsigned long request, void *arg)
+{
+ int i = 0;
+ int result;
+ while (1) {
+ if (devices[index].subdev_fds[i] == -1)
+ return -1;
+ printf("g_ctrl failed, trying...\n");
+ result = SYS_IOCTL(devices[index].subdev_fds[i], request, arg);
+ printf("subdev %d result %d\n", i, result);
+ if (result == 0)
+ return 0;
+ i++;
+ }
+ return -1;
+}
+
int v4l2_ioctl(int fd, unsigned long int request, ...)
{
void *arg;
@@ -1193,14 +1210,20 @@ no_capture_request:
switch (request) {
case VIDIOC_QUERYCTRL:
result = v4lconvert_vidioc_queryctrl(devices[index].convert, arg);
+ if (result == -1)
+ result = v4l2_propagate_ioctl(index, request, arg);
break;
case VIDIOC_G_CTRL:
result = v4lconvert_vidioc_g_ctrl(devices[index].convert, arg);
+ if (result == -1)
+ result = v4l2_propagate_ioctl(index, request, arg);
break;
case VIDIOC_S_CTRL:
result = v4lconvert_vidioc_s_ctrl(devices[index].convert, arg);
+ if (result == -1)
+ result = v4l2_propagate_ioctl(index, request, arg);
break;
case VIDIOC_G_EXT_CTRLS:
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Mauro Carvalho Chehab <mchehab@s-opensource.com> |
|---|---|
| Date | 2017-04-26 13:20 +0200 |
| Subject | Re: [patch] propagating controls in libv4l2 was Re: support autofocus / autogain in libv4l2 |
| Message-ID | <tAt9f-1vX-3@gated-at.bofh.it> |
| In reply to | #1631389 |
Hi Pavel,
Em Wed, 26 Apr 2017 12:53:00 +0200
Pavel Machek <pavel@ucw.cz> escreveu:
> Hi!
>
> > > > IMO, the best place for autofocus is at libv4l2. Putting it on a
> > > > separate "video server" application looks really weird for me.
> > >
> > > Well... let me see. libraries are quite limited -- it is hard to open
> > > files, or use threads/have custom main loop. It may be useful to
> > > switch resolutions -- do autofocus/autogain at lower resolution, then
> > > switch to high one for taking picture. It would be good to have that
> > > in "system" code, but I'm not at all sure libv4l2 design will allow
> > > that.
> >
> > I don't see why it would be hard to open files or have threads inside
> > a library. There are several libraries that do that already, specially
> > the ones designed to be used on multimidia apps.
>
> Well, This is what the libv4l2 says:
>
> This file implements libv4l2, which offers v4l2_ prefixed versions
> of
> open/close/etc. The API is 100% the same as directly opening
> /dev/videoX
> using regular open/close/etc, the big difference is that format
> conversion
>
> but if I open additional files in v4l2_open(), API is no longer the
> same, as unix open() is defined to open just one file descriptor.
>
> Now. There is autogain support in libv4lconvert, but it expects to use
> same fd for camera and for the gain... which does not work with
> subdevs.
>
> Of course, opening subdevs by name like this is not really
> acceptable. But can you suggest a method that is?
There are two separate things here:
1) Autofoucs for a device that doesn't use subdev API
2) libv4l2 support for devices that require MC and subdev API
for (1), it should use the /dev/videoX device that was opened with
v4l2_open().
For (2), libv4l2 should be aware of MC and subdev APIs. Sakari
once tried to write a libv4l2 plugin for OMAP3, but never finished it.
A more recent trial were to add a libv4l2 plugin for Exynos.
Unfortunately, none of those code got merged. Last time I checked,
the Exynos plugin was almost ready to be merged, but Sakari asked
some changes on it. The developer that was working on it got job on
some other company. Last time I heard from him, he was still interested
on finishing his work, but in the need to setup a test environment
using his own devices.
So, currently, there's no code at all adding MC/subdev API
support merged at libv4l2.
-
IMHO, the right thing to do with regards to autofocus is to
implement it via a processing module, assuming that just one
video device is opened.
Then, add a N900 plugin to make libv4l2 aware of OMAP3 specifics.
After that, rework at the processing module to let it use a
different file descriptor if such plugin is in usage.
-
The hole idea is that a libv4l2 client, running on a N900 device
would just open a fake /dev/video0. Internally, libv4l2 will
open whatever video nodes it needs to control the device, exporting
all hardware capabilities (video formats, controls, resolutions,
etc) as if it was a normal V4L2 camera, hiding all dirty details
about MC and subdev APIs from userspace application.
This way, a normal application, like xawtv, tvtime, camorama,
zbar, mplayer, vlc, ... will work without any changes.
>
> Thanks,
> Pavel
>
> commit 4cf9d10ead014c0db25452e4bb9cd144632407c3
> Author: Pavel <pavel@ucw.cz>
> Date: Wed Apr 26 11:38:04 2017 +0200
>
> Add subdevices.
>
> diff --git a/lib/libv4l2/libv4l2-priv.h b/lib/libv4l2/libv4l2-priv.h
> index 343db5e..a6bc48e 100644
> --- a/lib/libv4l2/libv4l2-priv.h
> +++ b/lib/libv4l2/libv4l2-priv.h
> @@ -26,6 +26,7 @@
> #include "../libv4lconvert/libv4lsyscall-priv.h"
>
> #define V4L2_MAX_DEVICES 16
> +#define V4L2_MAX_SUBDEVS 8
> /* Warning when making this larger the frame_queued and frame_mapped members of
> the v4l2_dev_info struct can no longer be a bitfield, so the code needs to
> be adjusted! */
> @@ -104,6 +105,7 @@ struct v4l2_dev_info {
> void *plugin_library;
> void *dev_ops_priv;
> const struct libv4l_dev_ops *dev_ops;
> + int subdev_fds[V4L2_MAX_SUBDEVS];
> };
>
> /* From v4l2-plugin.c */
> diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
> index 0ba0a88..edc9642 100644
> --- a/lib/libv4l2/libv4l2.c
> +++ b/lib/libv4l2/libv4l2.c
> @@ -1,3 +1,4 @@
> +/* -*- c-file-style: "linux" -*- */
> /*
> # (C) 2008 Hans de Goede <hdegoede@redhat.com>
>
> @@ -789,18 +790,25 @@ no_capture:
>
> /* Note we always tell v4lconvert to optimize src fmt selection for
> our default fps, the only exception is the app explicitly selecting
> - a fram erate using the S_PARM ioctl after a S_FMT */
> + a frame rate using the S_PARM ioctl after a S_FMT */
> if (devices[index].convert)
> v4lconvert_set_fps(devices[index].convert, V4L2_DEFAULT_FPS);
> v4l2_update_fps(index, &parm);
>
> + devices[index].subdev_fds[0] = SYS_OPEN("/dev/video_sensor", O_RDWR, 0);
> + devices[index].subdev_fds[1] = SYS_OPEN("/dev/video_focus", O_RDWR, 0);
> + devices[index].subdev_fds[2] = -1;
> +
> + printf("Sensor: %d, focus: %d\n", devices[index].subdev_fds[0],
> + devices[index].subdev_fds[1]);
> +
> V4L2_LOG("open: %d\n", fd);
>
> return fd;
> }
>
> /* Is this an fd for which we are emulating v4l1 ? */
> -static int v4l2_get_index(int fd)
> +int v4l2_get_index(int fd)
> {
> int index;
>
>
> commit 1d6a9ce121f53e8f2e38549eed597a3c3dea5233
> Author: Pavel <pavel@ucw.cz>
> Date: Wed Apr 26 12:34:04 2017 +0200
>
> Enable ioctl propagation.
>
> diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
> index edc9642..6dab661 100644
> --- a/lib/libv4l2/libv4l2.c
> +++ b/lib/libv4l2/libv4l2.c
> @@ -1064,6 +1064,23 @@ static int v4l2_s_fmt(int index, struct v4l2_format *dest_fmt)
> return 0;
> }
>
> +static int v4l2_propagate_ioctl(int index, unsigned long request, void *arg)
> +{
> + int i = 0;
> + int result;
> + while (1) {
> + if (devices[index].subdev_fds[i] == -1)
> + return -1;
> + printf("g_ctrl failed, trying...\n");
> + result = SYS_IOCTL(devices[index].subdev_fds[i], request, arg);
> + printf("subdev %d result %d\n", i, result);
> + if (result == 0)
> + return 0;
> + i++;
> + }
> + return -1;
> +}
> +
> int v4l2_ioctl(int fd, unsigned long int request, ...)
> {
> void *arg;
> @@ -1193,14 +1210,20 @@ no_capture_request:
> switch (request) {
> case VIDIOC_QUERYCTRL:
> result = v4lconvert_vidioc_queryctrl(devices[index].convert, arg);
> + if (result == -1)
> + result = v4l2_propagate_ioctl(index, request, arg);
> break;
>
> case VIDIOC_G_CTRL:
> result = v4lconvert_vidioc_g_ctrl(devices[index].convert, arg);
> + if (result == -1)
> + result = v4l2_propagate_ioctl(index, request, arg);
> break;
>
> case VIDIOC_S_CTRL:
> result = v4lconvert_vidioc_s_ctrl(devices[index].convert, arg);
> + if (result == -1)
> + result = v4l2_propagate_ioctl(index, request, arg);
> break;
>
> case VIDIOC_G_EXT_CTRLS:
>
>
Thanks,
Mauro
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-26 15:30 +0200 |
| Subject | [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) |
| Message-ID | <tAvb4-2OA-13@gated-at.bofh.it> |
| In reply to | #1631404 |
[Multipart message — attachments visible in raw view] — view raw
Hi!
> > > I don't see why it would be hard to open files or have threads inside
> > > a library. There are several libraries that do that already, specially
> > > the ones designed to be used on multimidia apps.
> >
> > Well, This is what the libv4l2 says:
> >
> > This file implements libv4l2, which offers v4l2_ prefixed versions
> > of
> > open/close/etc. The API is 100% the same as directly opening
> > /dev/videoX
> > using regular open/close/etc, the big difference is that format
> > conversion
> >
> > but if I open additional files in v4l2_open(), API is no longer the
> > same, as unix open() is defined to open just one file descriptor.
> >
> > Now. There is autogain support in libv4lconvert, but it expects to use
> > same fd for camera and for the gain... which does not work with
> > subdevs.
> >
> > Of course, opening subdevs by name like this is not really
> > acceptable. But can you suggest a method that is?
>
> There are two separate things here:
>
> 1) Autofoucs for a device that doesn't use subdev API
> 2) libv4l2 support for devices that require MC and subdev API
Actually there are three: 0) autogain. Unfortunately, I need autogain
first before autofocus has a chance...
And that means... bayer10 support for autogain.
Plus, I changed avg_lum to long long. Quick calculation tells me int
could overflow with few megapixel sensor.
Oh, btw http://ytse.tricolour.net/docs/LowLightOptimization.html no
longer works.
Regards,
Pavel
diff --git a/lib/libv4lconvert/processing/autogain.c b/lib/libv4lconvert/processing/autogain.c
index c6866d6..0b52d0f 100644
--- a/lib/libv4lconvert/processing/autogain.c
+++ b/lib/libv4lconvert/processing/autogain.c
@@ -68,6 +71,41 @@ static void autogain_adjust(struct v4l2_queryctrl *ctrl, int *value,
}
}
+static int get_luminosity_bayer10(uint16_t *buf, const struct v4l2_format *fmt)
+{
+ long long avg_lum = 0;
+ int x, y;
+
+ buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
+ fmt->fmt.pix.width / 4;
+
+ for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
+ for (x = 0; x < fmt->fmt.pix.width / 2; x++)
+ avg_lum += *buf++;
+ buf += fmt->fmt.pix.bytesperline - fmt->fmt.pix.width / 2;
+ }
+ avg_lum /= fmt->fmt.pix.height * fmt->fmt.pix.width / 4;
+ avg_lum /= 4;
+ return avg_lum;
+}
+
+static int get_luminosity_bayer8(unsigned char *buf, const struct v4l2_format *fmt)
+{
+ long long avg_lum = 0;
+ int x, y;
+
+ buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
+ fmt->fmt.pix.width / 4;
+
+ for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
+ for (x = 0; x < fmt->fmt.pix.width / 2; x++)
+ avg_lum += *buf++;
+ buf += fmt->fmt.pix.bytesperline - fmt->fmt.pix.width / 2;
+ }
+ avg_lum /= fmt->fmt.pix.height * fmt->fmt.pix.width / 4;
+ return avg_lum;
+}
+
/* auto gain and exposure algorithm based on the knee algorithm described here:
http://ytse.tricolour.net/docs/LowLightOptimization.html */
static int autogain_calculate_lookup_tables(
@@ -100,17 +142,16 @@ static int autogain_calculate_lookup_tables(
switch (fmt->fmt.pix.pixelformat) {
+ case V4L2_PIX_FMT_SGBRG10:
+ case V4L2_PIX_FMT_SGRBG10:
+ case V4L2_PIX_FMT_SBGGR10:
+ case V4L2_PIX_FMT_SRGGB10:
+ avg_lum = get_luminosity_bayer10((void *) buf, fmt);
+ break;
+
case V4L2_PIX_FMT_SGBRG8:
case V4L2_PIX_FMT_SGRBG8:
case V4L2_PIX_FMT_SBGGR8:
case V4L2_PIX_FMT_SRGGB8:
- buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
- fmt->fmt.pix.width / 4;
-
- for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
- for (x = 0; x < fmt->fmt.pix.width / 2; x++)
- avg_lum += *buf++;
- buf += fmt->fmt.pix.bytesperline - fmt->fmt.pix.width / 2;
- }
- avg_lum /= fmt->fmt.pix.height * fmt->fmt.pix.width / 4;
+ avg_lum = get_luminosity_bayer8(buf, fmt);
break;
case V4L2_PIX_FMT_RGB24:
diff --git a/lib/libv4lconvert/processing/libv4lprocessing.c b/lib/libv4lconvert/processing/libv4lprocessing.c
index b061f50..b98d024 100644
--- a/lib/libv4lconvert/processing/libv4lprocessing.c
+++ b/lib/libv4lconvert/processing/libv4lprocessing.c
@@ -164,6 +165,10 @@ void v4lprocessing_processing(struct v4lprocessing_data *data,
case V4L2_PIX_FMT_SGRBG8:
case V4L2_PIX_FMT_SBGGR8:
case V4L2_PIX_FMT_SRGGB8:
+ case V4L2_PIX_FMT_SGBRG10:
+ case V4L2_PIX_FMT_SGRBG10:
+ case V4L2_PIX_FMT_SBGGR10:
+ case V4L2_PIX_FMT_SRGGB10:
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
break;
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> |
|---|---|
| Date | 2017-04-26 17:50 +0200 |
| Subject | Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) |
| Message-ID | <tAxmy-4e9-17@gated-at.bofh.it> |
| In reply to | #1631457 |
Hi,
On 26.04.2017 16:23, Pavel Machek wrote:
> Hi!
>
>>>> I don't see why it would be hard to open files or have threads inside
>>>> a library. There are several libraries that do that already, specially
>>>> the ones designed to be used on multimidia apps.
>>>
>>> Well, This is what the libv4l2 says:
>>>
>>> This file implements libv4l2, which offers v4l2_ prefixed versions
>>> of
>>> open/close/etc. The API is 100% the same as directly opening
>>> /dev/videoX
>>> using regular open/close/etc, the big difference is that format
>>> conversion
>>>
>>> but if I open additional files in v4l2_open(), API is no longer the
>>> same, as unix open() is defined to open just one file descriptor.
>>>
>>> Now. There is autogain support in libv4lconvert, but it expects to use
>>> same fd for camera and for the gain... which does not work with
>>> subdevs.
>>>
>>> Of course, opening subdevs by name like this is not really
>>> acceptable. But can you suggest a method that is?
>>
>> There are two separate things here:
>>
>> 1) Autofoucs for a device that doesn't use subdev API
>> 2) libv4l2 support for devices that require MC and subdev API
>
> Actually there are three: 0) autogain. Unfortunately, I need autogain
> first before autofocus has a chance...
>
> And that means... bayer10 support for autogain.
>
> Plus, I changed avg_lum to long long. Quick calculation tells me int
> could overflow with few megapixel sensor.
>
> Oh, btw http://ytse.tricolour.net/docs/LowLightOptimization.html no
> longer works.
>
> Regards,
> Pavel
>
> diff --git a/lib/libv4lconvert/processing/autogain.c b/lib/libv4lconvert/processing/autogain.c
> index c6866d6..0b52d0f 100644
> --- a/lib/libv4lconvert/processing/autogain.c
> +++ b/lib/libv4lconvert/processing/autogain.c
> @@ -68,6 +71,41 @@ static void autogain_adjust(struct v4l2_queryctrl *ctrl, int *value,
> }
> }
>
> +static int get_luminosity_bayer10(uint16_t *buf, const struct v4l2_format *fmt)
> +{
> + long long avg_lum = 0;
> + int x, y;
> +
> + buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
> + fmt->fmt.pix.width / 4;
> +
> + for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
> + for (x = 0; x < fmt->fmt.pix.width / 2; x++)
That would take some time :). AIUI, we have NEON support in ARM kernels
(CONFIG_KERNEL_MODE_NEON), I wonder if it makes sense (me) to convert
the above loop to NEON-optimized when it comes to it? Are there any
drawbacks in using NEON code in kernel?
> + avg_lum += *buf++;
> + buf += fmt->fmt.pix.bytesperline - fmt->fmt.pix.width / 2;
> + }
> + avg_lum /= fmt->fmt.pix.height * fmt->fmt.pix.width / 4;
> + avg_lum /= 4;
> + return avg_lum;
> +}
> +
> +static int get_luminosity_bayer8(unsigned char *buf, const struct v4l2_format *fmt)
> +{
> + long long avg_lum = 0;
> + int x, y;
> +
> + buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
> + fmt->fmt.pix.width / 4;
> +
> + for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
> + for (x = 0; x < fmt->fmt.pix.width / 2; x++)
ditto.
> + avg_lum += *buf++;
> + buf += fmt->fmt.pix.bytesperline - fmt->fmt.pix.width / 2;
> + }
> + avg_lum /= fmt->fmt.pix.height * fmt->fmt.pix.width / 4;
> + return avg_lum;
> +}
> +
> /* auto gain and exposure algorithm based on the knee algorithm described here:
> http://ytse.tricolour.net/docs/LowLightOptimization.html */
> static int autogain_calculate_lookup_tables(
> @@ -100,17 +142,16 @@ static int autogain_calculate_lookup_tables(
> switch (fmt->fmt.pix.pixelformat) {
> + case V4L2_PIX_FMT_SGBRG10:
> + case V4L2_PIX_FMT_SGRBG10:
> + case V4L2_PIX_FMT_SBGGR10:
> + case V4L2_PIX_FMT_SRGGB10:
> + avg_lum = get_luminosity_bayer10((void *) buf, fmt);
> + break;
> +
> case V4L2_PIX_FMT_SGBRG8:
> case V4L2_PIX_FMT_SGRBG8:
> case V4L2_PIX_FMT_SBGGR8:
> case V4L2_PIX_FMT_SRGGB8:
> - buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
> - fmt->fmt.pix.width / 4;
> -
> - for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
> - for (x = 0; x < fmt->fmt.pix.width / 2; x++)
> - avg_lum += *buf++;
> - buf += fmt->fmt.pix.bytesperline - fmt->fmt.pix.width / 2;
> - }
> - avg_lum /= fmt->fmt.pix.height * fmt->fmt.pix.width / 4;
> + avg_lum = get_luminosity_bayer8(buf, fmt);
> break;
>
> case V4L2_PIX_FMT_RGB24:
> diff --git a/lib/libv4lconvert/processing/libv4lprocessing.c b/lib/libv4lconvert/processing/libv4lprocessing.c
> index b061f50..b98d024 100644
> --- a/lib/libv4lconvert/processing/libv4lprocessing.c
> +++ b/lib/libv4lconvert/processing/libv4lprocessing.c
> @@ -164,6 +165,10 @@ void v4lprocessing_processing(struct v4lprocessing_data *data,
> case V4L2_PIX_FMT_SGRBG8:
> case V4L2_PIX_FMT_SBGGR8:
> case V4L2_PIX_FMT_SRGGB8:
> + case V4L2_PIX_FMT_SGBRG10:
> + case V4L2_PIX_FMT_SGRBG10:
> + case V4L2_PIX_FMT_SBGGR10:
> + case V4L2_PIX_FMT_SRGGB10:
> case V4L2_PIX_FMT_RGB24:
> case V4L2_PIX_FMT_BGR24:
> break;
>
>
>
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-04-27 01:00 +0200 |
| Subject | Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) |
| Message-ID | <tAE4F-mI-9@gated-at.bofh.it> |
| In reply to | #1631544 |
[Multipart message — attachments visible in raw view] — view raw
Hi!
> >>There are two separate things here:
> >>
> >>1) Autofoucs for a device that doesn't use subdev API
> >>2) libv4l2 support for devices that require MC and subdev API
> >
> >Actually there are three: 0) autogain. Unfortunately, I need autogain
> >first before autofocus has a chance...
> >
> >And that means... bayer10 support for autogain.
> >
> >Plus, I changed avg_lum to long long. Quick calculation tells me int
> >could overflow with few megapixel sensor.
> >
> >Oh, btw http://ytse.tricolour.net/docs/LowLightOptimization.html no
> >longer works.
> >
> >Regards,
> > Pavel
> >
> >diff --git a/lib/libv4lconvert/processing/autogain.c b/lib/libv4lconvert/processing/autogain.c
> >index c6866d6..0b52d0f 100644
> >--- a/lib/libv4lconvert/processing/autogain.c
> >+++ b/lib/libv4lconvert/processing/autogain.c
> >@@ -68,6 +71,41 @@ static void autogain_adjust(struct v4l2_queryctrl *ctrl, int *value,
> > }
> > }
> >
> >+static int get_luminosity_bayer10(uint16_t *buf, const struct v4l2_format *fmt)
> >+{
> >+ long long avg_lum = 0;
> >+ int x, y;
> >+
> >+ buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
> >+ fmt->fmt.pix.width / 4;
> >+
> >+ for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
> >+ for (x = 0; x < fmt->fmt.pix.width / 2; x++)
>
> That would take some time :). AIUI, we have NEON support in ARM kernels
> (CONFIG_KERNEL_MODE_NEON), I wonder if it makes sense (me) to convert the
> above loop to NEON-optimized when it comes to it? Are there any drawbacks in
> using NEON code in kernel?
Well, thanks for offer. This is actualy libv4l2.
But I'd say NEON conversion is not neccessary anytime soon. First,
this is just trying to get average luminosity. We can easily skip
quite a lot of pixels, and still get reasonable answer.
Second, omap3isp actually has a hardware block computing statistics
for us. We just don't use it for simplicity.
(But if you want to play with camera, I'll get you patches; there's
ton of work to be done, both kernel and userspace :-).
Regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> |
|---|---|
| Date | 2017-04-27 08:00 +0200 |
| Subject | Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) |
| Message-ID | <tAKD7-4DF-1@gated-at.bofh.it> |
| In reply to | #1631784 |
On 27.04.2017 01:51, Pavel Machek wrote:
> Hi!
>
>>>> There are two separate things here:
>>>>
>>>> 1) Autofoucs for a device that doesn't use subdev API
>>>> 2) libv4l2 support for devices that require MC and subdev API
>>>
>>> Actually there are three: 0) autogain. Unfortunately, I need autogain
>>> first before autofocus has a chance...
>>>
>>> And that means... bayer10 support for autogain.
>>>
>>> Plus, I changed avg_lum to long long. Quick calculation tells me int
>>> could overflow with few megapixel sensor.
>>>
>>> Oh, btw http://ytse.tricolour.net/docs/LowLightOptimization.html no
>>> longer works.
>>>
>>> Regards,
>>> Pavel
>>>
>>> diff --git a/lib/libv4lconvert/processing/autogain.c b/lib/libv4lconvert/processing/autogain.c
>>> index c6866d6..0b52d0f 100644
>>> --- a/lib/libv4lconvert/processing/autogain.c
>>> +++ b/lib/libv4lconvert/processing/autogain.c
>>> @@ -68,6 +71,41 @@ static void autogain_adjust(struct v4l2_queryctrl *ctrl, int *value,
>>> }
>>> }
>>>
>>> +static int get_luminosity_bayer10(uint16_t *buf, const struct v4l2_format *fmt)
>>> +{
>>> + long long avg_lum = 0;
>>> + int x, y;
>>> +
>>> + buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
>>> + fmt->fmt.pix.width / 4;
>>> +
>>> + for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
>>> + for (x = 0; x < fmt->fmt.pix.width / 2; x++)
>>
>> That would take some time :). AIUI, we have NEON support in ARM kernels
>> (CONFIG_KERNEL_MODE_NEON), I wonder if it makes sense (me) to convert the
>> above loop to NEON-optimized when it comes to it? Are there any drawbacks in
>> using NEON code in kernel?
>
> Well, thanks for offer. This is actualy libv4l2.
>
Oh, somehow I got confused that this is kernel code :)
> But I'd say NEON conversion is not neccessary anytime soon. First,
> this is just trying to get average luminosity. We can easily skip
> quite a lot of pixels, and still get reasonable answer.
>
> Second, omap3isp actually has a hardware block computing statistics
> for us. We just don't use it for simplicity.
>
Right, I forgot about that.
> (But if you want to play with camera, I'll get you patches; there's
> ton of work to be done, both kernel and userspace :-).
Well, I saw a low hanging fruit I thought I can convert to NEON in a day
or two, while having some rest from the huge "project" I am devoting all
my spare time recently (rebasing hildon/maemo 5 on top of devuan
Jessie). Still, if there is something relatively small to be done, just
email me and I'll have a look.
Regards,
Ivo
[toc] | [prev] | [next] | [standalone]
| From | Russell King - ARM Linux <linux@armlinux.org.uk> |
|---|---|
| Date | 2017-05-03 21:10 +0200 |
| Subject | Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) |
| Message-ID | <tD7OW-13Q-7@gated-at.bofh.it> |
| In reply to | #1631544 |
On Wed, Apr 26, 2017 at 06:43:54PM +0300, Ivaylo Dimitrov wrote:
> >+static int get_luminosity_bayer10(uint16_t *buf, const struct v4l2_format *fmt)
> >+{
> >+ long long avg_lum = 0;
> >+ int x, y;
> >+
> >+ buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
> >+ fmt->fmt.pix.width / 4;
> >+
> >+ for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
> >+ for (x = 0; x < fmt->fmt.pix.width / 2; x++)
>
> That would take some time :). AIUI, we have NEON support in ARM kernels
> (CONFIG_KERNEL_MODE_NEON), I wonder if it makes sense (me) to convert the
> above loop to NEON-optimized when it comes to it? Are there any drawbacks in
> using NEON code in kernel?
Using neon without the VFP state saved and restored corrupts userspace's
FP state. So, you have to save the entire VFP state to use neon in kernel
mode. There are helper functions for this: kernel_neon_begin() and
kernel_neon_end().
You can't build C code with the compiler believing that neon is available
as the compiler could emit neon instructions in unprotected kernel code.
Note that kernel_neon_begin() is only allowed to be called outside
interrupt context and with preemption disabled.
Given that, do we really want to be walking over multi-megabytes of image
data in the kernel with preemption disabled - it sounds like a recipe for
a very sluggish system. I think this should (and can only sensibly be
done) in userspace.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
[toc] | [prev] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2017-05-03 22:00 +0200 |
| Subject | Re: [patch] autogain support for bayer10 format (was Re: [patch] propagating controls in libv4l2) |
| Message-ID | <tD8Bj-1oE-3@gated-at.bofh.it> |
| In reply to | #1635220 |
[Multipart message — attachments visible in raw view] — view raw
On Wed 2017-05-03 20:05:56, Russell King - ARM Linux wrote:
> On Wed, Apr 26, 2017 at 06:43:54PM +0300, Ivaylo Dimitrov wrote:
> > >+static int get_luminosity_bayer10(uint16_t *buf, const struct v4l2_format *fmt)
> > >+{
> > >+ long long avg_lum = 0;
> > >+ int x, y;
> > >+
> > >+ buf += fmt->fmt.pix.height * fmt->fmt.pix.bytesperline / 4 +
> > >+ fmt->fmt.pix.width / 4;
> > >+
> > >+ for (y = 0; y < fmt->fmt.pix.height / 2; y++) {
> > >+ for (x = 0; x < fmt->fmt.pix.width / 2; x++)
> >
> > That would take some time :). AIUI, we have NEON support in ARM kernels
> > (CONFIG_KERNEL_MODE_NEON), I wonder if it makes sense (me) to convert the
> > above loop to NEON-optimized when it comes to it? Are there any drawbacks in
> > using NEON code in kernel?
>
> Using neon without the VFP state saved and restored corrupts userspace's
> FP state. So, you have to save the entire VFP state to use neon in kernel
> mode. There are helper functions for this: kernel_neon_begin() and
> kernel_neon_end().
...
> Given that, do we really want to be walking over multi-megabytes of image
> data in the kernel with preemption disabled - it sounds like a recipe for
> a very sluggish system. I think this should (and can only sensibly be
> done) in userspace.
The patch was for libv4l2. (And I explained why we don't need to
overoptimize this.)
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web