Getting screen brightness in a Linux kernel module - linux

I'm trying to get current screen brightness in my Linux kernel module. However, I don't know how can I access the brightness variable, though easily get it in an user-space application using the sysfs interface.
Please let me know a clue about this problem.
Thank you.

Usually modern Desktops (GNOME/XFCE4/KDE) provide utilities to change the brightness but answering your question you should look on your /sys/class directory for it. HINT: look for backlight you will find one driver which provides you that functionality.
In my case it is samsung-laptop module and intel.

For me
/sys/class/backlight/intel_backlight
$ cat actual_brightness
This worked to get the actual brightness.You might want to go to /sys/class/backlight and try to ls to see whats in store.

You can change directory to /sys/class/backlight/acpi_video0 and then open actual_brightness file.
cd /sys/class/backlight/acpi_video0
cat actual_brightness

Related

How do I enable the splash screen on dm 365 during uboot?

I am using a custom davinci board running Arago project. I am using analog video out (PAL), and though the OLED display powers on with uboot, no image comes till the kernel has finished loading. I want to display a logo as soon as uboot starts and display powers on. I tried adding
#define CONFIG_SPLASH_SCREEN
in the uboot config file, but that doesn't work.
One approach I can think of is to put an image in the NAND memory, and then use the
setenv splashimage <address>
command to display it during uboot. But the problem is, I do not know how to put the image in the NAND memory in a particular address.
Alternative methods are also welcome.
Thanks!
The CONFIG_SPLASH_SCREEN only tells U-Boot to include the code required for supporting splash screens. It says absolutely nothing about how to display the splash screen or where to find it. It only provides you with helpful functionality to achieve that goal.
There is no need to put your image at a specific address in NAND. If your U-Boot can access the filesystem, you could just have the image in a file. You could also embed the image in the U-Boot image if you like. That's entirely up to you. The functionality included by the CONFIG_SPLASH_SCREEN will help you load an image from any number of sources.
The trick is getting it displayed. You'll need to teach U-Boot enough about your graphics hardware to get the image out. On most SoCs, that's just a matter of setting up the framebuffer, loading your image into it, and telling the hardware to start clocking it out.
It doesn't look like someone has written a framebuffer driver for the DM365, so you'll have to do that yourself. Or maybe ask on the mailing list if anyone has done it but not contributed it back yet. If you have to do the work yourself, it's probably easiest to start from the Linux driver and port only the bits you need.
You'll find here the official documentation for u-boot's splash. It has an example on how to load the file into nand, using tftp.
Find here how to set the tftp server in case you don't already have.

how to open system date, sound, display properties in linux?

I know there are APIs in windows like "desk.cpl", "timedate.cpl" , "sndvol".
I use these in system command to open from a SLOT.
I want to know about these alternatives for Linux.
Please help me is there any command to open these 3 from terminal I only want to show this.
Execute following command in terminal
gnome-control-center display
gnome-control-center datetime
gnome-control-center sound
As a Linux user I do not know what those MS-Windows "things" you mention actually do and you appear to take that for granted. So I have to guess here:
to get the current system time on shell level you can use date. See the man page for details: man date.
for the current volume setting, not easy to answer, since Linux is a very modular system. Most likely you could ask DBus about that, but this really depends on what desktop environment and what sound system you use. You might try amixer get PCM|tail -n1|sed -r 's/.*\[(.*)%\].*/\1/', but as said that really depends...
No idea what "desk.cpl" does, so I cannot say anything about this "thing".

How can I get edge events via GPIO on Linux without a busy-loop?

I'm working an a system with embedded Linux (Kernel 2.6.31).
It is a AT91SAM9G20 chip inside, and some of the Pins are forwarded to the outside.
Now I want to use them as GPIO Inputs.
I read the gpio.txt documentation about using the GPIOs via filesystem, and that works very well 'til here. I connected some switches to the gpio-pins and I can see the result in /sys/class/gpio/gpioX/value. But now I'd like to react on a change without busy-waiting in a loop. (i.e echo "Switch1 was pressed").
I guess I need interrupts here, but I couldn't find out how to use them without writing my own kernel driver. I'm relatively new to Linux and C (I normally program in Java), so I'd like to handle the Interrupts via sysfs too. But my problem is, that there is no "edge"-file in my GPIO directory (I guess because this is only since Kernel version 2.6.33+). Is that right? Instead of "edge" I've got a uevent file in there, which is not described in gpio.txt.
In the gpio.txt documentation there was a Standard Kernel Driver mentioned: "gpio_keys". Is it possible to use this for my problem?
I guess it would be better to work with this driver than allowing a userspace program to manipulate kernel tasks.
I found a lot of codesnippets for writing my own driver, but I wasn't even able to find out which of the 600 gpio.h files to include, and how to refer to the library (cross compiler couldn't find the gpio.h file).
Sorry for newbie questions, I hope you could give me some advices.
Thanks in advance
See this for an example on how to do that. Basically, the thing you're missing is the usage of the select or poll system calls.

Hardware recognition in user space Linux

I want to be able to inspect my Linux machine hardware in C.
How do I get the information that appear in dmesg in C ?
For example, for keyboard the message is input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input0
I want to get in my program the label, AT Translated Set 2, and the path, /devices/platform/i8042/serio0/input/input0.
Any idea how to do so ?
amit
You can also look at the contents of files in /proc.
/proc/version, /proc/ioports, /proc/iomem, /proc/meminfo, and others have a lot of information in them.
The files under /proc/bus have additional information about the system's hardware devices.
I'd also recommend looking at the source code for usbutils and pciutils for example code to get the output from the lsusb and lspci commands respectively.
It uses the klogctl call.
Best thing is to read the source code yourself, it can be downloaded here: util-linux
You would want to use libhal, and connect to the hal daemon. If HAL isn't there, look for a mounted sysfs partition. Check out /sys/devices, or work backwards through /sys/bus.
If neither HAL nor sysfs is available, reconsider your approach or restrict your scope.

Change arguments that start up with JFS driver on linux

I am more common with the QNX os and I could change the arguments for the ide driver on startup. I wanted to change the arguments that get started in a linux kernel for the jfs filesystem which mounts a flash card. I can't seem to find a good web source for this information but I am sure I am not "googling" it right.
What are the different options available for the jfs/ide driver and where do I change them for the current running driver?
Thank you and I apologize this isn't exactly programming but this site always produces great answers when I ask a programming question so I figure it might help here too.
ok, i finally found out it is defined in the /etc/fstab file. Now I just need to find out what options are available and best for a compact flash card.
Options for most filesystems are shown in the "mount" manpage.
The ata driver may also have various tunables. You can probably change these in real time with "hdparm".
Some options might be filesystem create time options, in which case mkfs will document them.
See the relevant man pages.
If you want to pass options to jfs, you need to pass them as part of kernel boot
line, which is specified in your grub.conf or lilo.conf file. You can find the supported
options in the Documentation/ directory of the kernel source, or the jfs source itself.
As for the recommended mount options, you need to look at the mount(8) man page.
I would recommend noatime,nodirtime at a mininum. The default is atime, which
causes the file inode to be updated everytime you look at a file.

Resources