From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Hans Verkuil <hans.verkuil@cisco.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Antti Palosaari <crope@iki.fi>,
Ricardo Ribalda <ricardo.ribalda@gmail.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Ramakrishnan Muthukrishnan <ramakrmu@cisco.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
linux-api@vger.kernel.org
Subject: Re: [PATCH 1/3] media: Fix ALSA and DVB representation at media controller API
Date: Mon, 26 Jan 2015 12:31:29 -0200 [thread overview]
Message-ID: <20150126123129.2076b9f8@recife.lan> (raw)
In-Reply-To: <CAGoCfixoSxspEzpCB95BVPXBrZr2gpDVWHbaikESsuB1V=WM1g@mail.gmail.com>
Em Mon, 26 Jan 2015 09:00:46 -0500
Devin Heitmueller <dheitmueller@kernellabs.com> escreveu:
> > For media-ctl, it is easier to handle major/minor, in order to identify
> > the associated devnode name. Btw, media-ctl currently assumes that all
> > devnode devices are specified by v4l.major/v4l.minor.
>
> I suspect part of the motivation for the "id" that corresponds to the
> adapter field was to make it easier to find the actual underlying
> device node.
Yes, that was the reason why, back in 2007, we believed that just id
would be enough. Yet, we never tried to implement it, until the end
of the last year.
> While it's trivial to convert a V4L device node from
> major/minor to the device node (since for major number is constant and
> the minor corresponds to the X in /dev/videoX), that's tougher with
> DVB adapters because of the hierarchical nature of the DVB device
> nodes. Having the adapter number makes it trivial to open
> /dev/dvb/adapterX.
>
> Perhaps my POSIX is rusty -- is there a way to identify the device
> node based on major minor without having to traverse the entire /dev
> tree?
It is actually trivial to get the device nodes once you have the
major/minor. The media-ctl library does that for you. See:
$ media-ctl --print-dot
digraph board {
rankdir=TB
n00000001 [label="{{<port0> 0} | cx25840 19-0044 | {<port1> 1 | <port2> 2}}", shape=Mrecord, style=filled, fillcolor=green]
n00000001:port1 -> n00000003
n00000001:port2 -> n00000004
n00000002 [label="{{} | NXP TDA18271HD | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
n00000002:port0 -> n00000005 [style=dashed]
n00000002:port0 -> n00000001:port0
n00000003 [label="cx231xx #0 video\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
n00000004 [label="cx231xx #0 vbi\n/dev/vbi0", shape=box, style=filled, fillcolor=yellow]
n00000005 [label="Fujitsu mb86A20s\n/dev/dvb/adapter0/frontend0", shape=box, style=filled, fillcolor=yellow]
n00000005 -> n00000006
n00000006 [label="demux\n/dev/dvb/adapter0/demux0", shape=box, style=filled, fillcolor=yellow]
n00000006 -> n00000007
n00000007 [label="dvr\n/dev/dvb/adapter0/dvr0", shape=box, style=filled, fillcolor=yellow]
n00000008 [label="dvb net\n/dev/dvb/adapter0/net0", shape=box, style=filled, fillcolor=yellow]
}
There are two routines inside the media-ctl libraries to convert from
major/minor into a devnode name like: /dev/dvb/adapter0/demux0.
The first one uses sysfs:
$ ls -la /sys/dev/char|grep dvb
lrwxrwxrwx. 1 root root 0 Jan 26 10:32 212:0 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1/dvb/dvb0.frontend0
lrwxrwxrwx. 1 root root 0 Jan 26 10:32 212:1 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1/dvb/dvb0.demux0
lrwxrwxrwx. 1 root root 0 Jan 26 10:32 212:2 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1/dvb/dvb0.dvr0
lrwxrwxrwx. 1 root root 0 Jan 26 10:32 212:3 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.1/dvb/dvb0.net0
Unfortunately, the sysfs nodes are "dvb0" for adapter0, so a patch is needed
to fix it:
http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-utils.git/commit/?h=dvb-media-ctl&id=d854a9bb24706dbfc878484e4538d79b1ac52aae
The second (and better) approach is to require udev to return the name of the
devnode. The logic, implemented at utils/media-ctl/libmediactl.c, inside
v4l-utils, is:
devnum = makedev(entity->info.v4l.major, entity->info.v4l.minor);
media_dbg(entity->media, "looking up device: %u:%u\n",
major(devnum), minor(devnum));
device = udev_device_new_from_devnum(udev, 'c', devnum);
Right now, by default, media-ctl will use the sysfs approach, except
if an extra option is called at ./configure, in order to enable it to
use the udev library.
IMHO, we should make udev the default behavior, if libudev-dev(el) is
there at compilation time.
Regards,
Mauro
next prev parent reply other threads:[~2015-01-26 14:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1422273497.git.mchehab@osg.samsung.com>
2015-01-26 12:47 ` [PATCH 1/3] media: Fix ALSA and DVB representation at media controller API Mauro Carvalho Chehab
2015-01-26 13:11 ` Hans Verkuil
2015-01-26 13:34 ` Mauro Carvalho Chehab
[not found] ` <20150126113416.311fb376-+RedX5hVuTR+urZeOPWqwQ@public.gmane.org>
2015-01-26 13:41 ` Hans Verkuil
2015-02-23 22:58 ` Laurent Pinchart
2015-02-24 3:51 ` Mauro Carvalho Chehab
2015-01-26 14:00 ` Devin Heitmueller
2015-01-26 14:31 ` Mauro Carvalho Chehab [this message]
[not found] ` <20150126123129.2076b9f8-+RedX5hVuTR+urZeOPWqwQ@public.gmane.org>
2015-01-26 14:41 ` Devin Heitmueller
[not found] ` <CAGoCfiwi0nj_9sYNzEFOp5BvedFe+HphJ2bVtx_bnBw3d-Bsyw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-23 13:55 ` Mauro Carvalho Chehab
2015-02-23 21:20 ` Laurent Pinchart
2015-02-24 2:51 ` Mauro Carvalho Chehab
2015-01-26 12:47 ` [PATCH 2/3] media: add new types for DVB devnodes Mauro Carvalho Chehab
2015-01-26 12:47 ` [PATCH 3/3] media: add a subdev type for tuner Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150126123129.2076b9f8@recife.lan \
--to=mchehab@osg.samsung.com \
--cc=crope@iki.fi \
--cc=dheitmueller@kernellabs.com \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@infradead.org \
--cc=ramakrmu@cisco.com \
--cc=ricardo.ribalda@gmail.com \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).