Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Identifying which driver for given device
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
statikregimen
Apprentice
Apprentice


Joined: 16 Jul 2011
Posts: 173
Location: USA/Michigan

PostPosted: Tue Aug 01, 2017 12:33 am    Post subject: Identifying which driver for given device Reply with quote

Greetings,
I've been at this for days and posting this because every time I do, I find the answer on my own shortly after. It's a curse.

Anyway, it seems like there has to be a way to identify what specifically one needs to enable in the kernel configuration based on the output of lspci and others (I mean somehow the kernel obviously works out which driver and/or module for each device). Yet, and endless barrage of googling has turned up no such method.

I've more or less gotten lucky so far on this machine but now have an elusive webcam and touchscreen that still need drivers. I know they are supported as I ran Debian Jessie on this machine.and they are also detected and modules loaded by Sabayon live image.

Using Sabayon live image, I've checked the output of lspci -k, lsusb, and usb-devices (both the camera and touchscreen are usb in this case), also lsmod. That is all great, but it only gives me some loose guidance. Some devices are apparently not so straight forward.

I swear I've done this a few times before, but it's lost to me now :(

I'm intentionally not posting any additional details about my hardware because I am asking how to find out for myself - not asking for someone to tell me!

Thanks in advance!

p.s. yes, i've looked at all the related wiki and doc articles I can find... from here and everywhere. And yes, I am aware that I'm overlooking something horribly obvious so go easy on me!


Last edited by statikregimen on Tue Aug 01, 2017 4:14 am; edited 1 time in total
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Tue Aug 01, 2017 12:47 am    Post subject: Reply with quote

This is out of date but still helps 99% of the time.

If you boot from a livecd, `make localyesconfig` in the kernel tree enables all currently loaded drivers.

You can also run e.g. `udevadm info /sys/bus/pci/devices/$foo` (no trailing slash) to get some info (it works on other things besides PCI), and the MODALIAS=* line it prints out can be passed directly to modinfo/modprobe to see what driver it thinks it should load.

99% of webcams are either GSPCA or UVC. Touchscreens are a bit more difficult but sometimes usbhid works fine. If it has a kernel driver loaded but doesn't work otherwise, try libinput.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Tue Aug 01, 2017 12:53 am    Post subject: Reply with quote

You can grep kernel sources for USB ID, or search http://cateee.net

Even plain net search can help, my webcam as an example.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Tue Aug 01, 2017 1:32 am    Post subject: Reply with quote

OP: you mentioned lsmod -k; did you mean lspci -k? The latter tells you which kernel driver is bound to a device. That is usually the hard part. Once you know what kernel driver serves the device, you need to find what Kconfig symbol will build that driver in the kernel of your choice. If you are lucky, the Kconfig symbol will have the driver's name as a substring, so you can find it using / to search in menuconfig. If you are not lucky, you may need to explore the kernel Makefiles to work backward from the source that implements the driver to the rule that causes that source to be built.
Back to top
View user's profile Send private message
josephg
l33t
l33t


Joined: 10 Jan 2016
Posts: 783
Location: usually offline

PostPosted: Tue Aug 01, 2017 1:48 am    Post subject: Re: Identifying which driver for given device Reply with quote

statikregimen wrote:
I've been at this for days and posting this because every time I do, I find the answer on my own shortly after. It's a curse.

lol perhaps you shouldn't wait for so many days, but post your problem right away.. after you find the answer on your own shortly after, don't forget to mark it solved. that would also help everyone else with similar problems ;)

statikregimen wrote:
I've more or less gotten lucky so far on this machine but now have an elusive webcam and touchscreen that still need drivers. I know they are supported as I ran Debian Jessie on this machine.and they are also detected and modules loaded by Sabayon live image.

load your Jessie and/or Sabayon and then look for kernel driver/modules in the output of
Code:
# lspci -knnvvv

_________________
"Growth for the sake of growth is the ideology of the cancer cell." Edward Abbey
Back to top
View user's profile Send private message
statikregimen
Apprentice
Apprentice


Joined: 16 Jul 2011
Posts: 173
Location: USA/Michigan

PostPosted: Tue Aug 01, 2017 1:55 am    Post subject: Reply with quote

Ant P. wrote:
This is out of date but still helps 99% of the time.

If you boot from a livecd, `make localyesconfig` in the kernel tree enables all currently loaded drivers.

You can also run e.g. `udevadm info /sys/bus/pci/devices/$foo` (no trailing slash) to get some info (it works on other things besides PCI), and the MODALIAS=* line it prints out can be passed directly to modinfo/modprobe to see what driver it thinks it should load.

99% of webcams are either GSPCA or UVC. Touchscreens are a bit more difficult but sometimes usbhid works fine. If it has a kernel driver loaded but doesn't work otherwise, try libinput.


Thanks I will try these. Especially the first sounds enticing. Do I just do that from a chroot into my installed system?

Sabayon appears to load UVC and V4L2 modules according to lsmod, so I enabled both of those but apparently still missing more.

Jaglover wrote:
You can grep kernel sources for USB ID, or search http://cateee.net

Even plain net search can help, my webcam as an example.


Thanks. I admittedly found something about using grep once, but couldn't find it again (forgot to bookmark). 'grep -nr' is enough? Also, it never occurred to me to search google like that - derp.
Back to top
View user's profile Send private message
statikregimen
Apprentice
Apprentice


Joined: 16 Jul 2011
Posts: 173
Location: USA/Michigan

PostPosted: Tue Aug 01, 2017 1:59 am    Post subject: Re: Identifying which driver for given device Reply with quote

josephg wrote:

lol perhaps you shouldn't wait for so many days, but post your problem right away.. after you find the answer on your own shortly after, don't forget to mark it solved. that would also help everyone else with similar problems ;)

load your Jessie and/or Sabayon and then look for kernel driver/modules in the output of
Code:
# lspci -knnvvv


haha! Thanks...good advice but usually I am self sufficient. I have to get pretty desperate before I reach out!

I will also try lspci with those options,because again: i'm looking for general strategy and approach than just purely how to set up one specific device. However, in this specific case they are apparently USB devices (this is on a laptop so bus type isn't usually immediately obvious).

EDIT: Wow..yea that helps a lot - the knnvvv options! Thank you!
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Aug 01, 2017 2:53 am    Post subject: Reply with quote

For me, the best i have found to get drivers name from a running system is
Code:
find /sys -name driver* -exec readlink '{}' \;

as it is not limited to pci devices.
Back to top
View user's profile Send private message
statikregimen
Apprentice
Apprentice


Joined: 16 Jul 2011
Posts: 173
Location: USA/Michigan

PostPosted: Tue Aug 01, 2017 4:13 am    Post subject: Reply with quote

Hu wrote:
OP: you mentioned lsmod -k; did you mean lspci -k?


sorry - typo... I meant lspci -k

krinn wrote:
For me, the best i have found to get drivers name from a running system is
Code:
find /sys -name driver* -exec readlink '{}' \;

as it is not limited to pci devices.


This looks like it very well could be the magic potion....I'm looking over the output now (or rather, will be when I'm done typing this).



I haven't been able to find any of these strategies with just searching, so again, thank you all! I feel like it's got to be a redundant topic, but I'll be dipped if I can find any of it.

EDIT: btw - here is what I'm working on to satisfy any curiosity: https://wiki.gentoo.org/wiki/Lenovo_Yoga_2_11-inch
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Wed Aug 02, 2017 2:18 am    Post subject: Reply with quote

krinn wrote:
For me, the best i have found to get drivers name from a running system is
Code:
find /sys -name driver* -exec readlink '{}' \;

as it is not limited to pci devices.
There's a chance that won't do what you want, and even if it does, there's a simpler way to do it. Since you didn't quote the glob, you're relying on (1) there being no matching files in the current directory and (2) the shell passing the glob through unchanged on failure (with the right options, failed globs are a hard failure and prevent running the command at all). As for the simpler way, you could use -printf '%l\n' to print the link target instead of running readlink.
Back to top
View user's profile Send private message
statikregimen
Apprentice
Apprentice


Joined: 16 Jul 2011
Posts: 173
Location: USA/Michigan

PostPosted: Wed Aug 02, 2017 3:21 am    Post subject: Reply with quote

Thanks, Hu.... I'll try your suggestion! The original suggestion seemed to work ok, but I don't fully understand your explanation. Mainly what is a glob?

In the mean time, I broke down and installed sys-kernel/kergen which comes with a couple useful tools. Plus, I happen to be quite proficient in Python so should be able to glean more knowledge from the source as well. It will also be a good stopgap until I master this subject.

I am getting there, though!
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Thu Aug 03, 2017 1:46 am    Post subject: Reply with quote

Read man 7 glob for a better background than I could readily enter here. (Ask if you still have questions after reading it. Always feel free to ask for elaborations on manual page references.)

Yes, the original will work fine (although perhaps less efficiently (although immeasurably so in most cases)), provided you have no files in the current directory with driver as an initial substring of the filename. If you do, the shell will expand driver* to that list instead of running find with a literal driver*. If you don't have such files, but you do have failglob (Bash name; other shells may name it otherwise, if they have it at all), then the command simply fails. Consider:
Code:
$ (shopt -s failglob; ls -l /foo?)
-bash: no match: /foo?
$ (shopt -u failglob; ls -l /foo?)
ls: cannot access '/foo?': No such file or directory
$ (shopt -s failglob; echo /foo?)
-bash: no match: /foo?
$ (shopt -u failglob; echo /foo?)
/foo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum