maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   Worse brightness setttings than OS2007 (https://talk.maemo.org/showthread.php?t=11958)

rm_you 2008-01-11 04:09

Re: Worse brightness setttings than OS2007
 
Yes, I am currently assuming 0 as sw level, just to set the current...

Thanks for explaining what the kernel is doing! The values I was seeing make a bit more sense now. I thought I was going insane, writing one value to the file and seeing another! >_>

I will look into reverse-engineering that, as it would be much better if the applet worked without the special kernel...

Oh, new version: http://cs.trinity.edu/~acm/debs/adva...ght-0.3.tar.gz
And source: http://cs.trinity.edu/~acm/debs/adva...0.3-src.tar.gz

The only real changes are a bit of code cleanup (doubt it has a performance impact) and it now checks to see which device it is on, to prevent blanking the screen on an n800 (since it lacks a transflective screen) and confusing the user.

Edit: an strace is here: http://pastebin.ca/850430
I'm not sure how to interpret that... I have done some strace interpretation for an Operating Systems class once, but nothing this complex. :(

fanoush 2008-01-11 09:02

Re: Worse brightness setttings than OS2007
 
Quote:

Originally Posted by rm_you (Post 125242)
an strace is here: http://pastebin.ca/850430
I'm not sure how to interpret that... I have done some strace interpretation for an Operating Systems class once, but nothing this complex. :(

Here is my try from 770, your strace build seems to not to resolve syscalls etc which makes it a bit more hard
Code:

Nokia-770-36:/# strace /usr/sbin/dsmetest -l 1
execve("/usr/sbin/dsmetest", ["/usr/sbin/dsmetest", "-l", "1"], [/* 47 vars */]) = 0
..
..
..
brk(0)                                  = 0x12000
brk(0x13000)                            = 0x13000
socket(PF_FILE, SOCK_STREAM, 0)        = 3
connect(3, {sa_family=AF_FILE, path="/tmp/dsmesock"}, 112) = 0
fcntl(3, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
write(3, "\f\0\0\0\206\2\0\0\1\0\0\0", 12) = 12
write(1, "brightness reqyest sent!\n", 25brightness reqyest sent!
) = 25
close(3)                                = 0
_exit(0)                                = ?

So basically it is the
Code:

write(3, "\f\0\0\0\206\2\0\0\1\0\0\0", 12) = 12
line. When starting with -l 2 it becomes
Code:

write(3, "\f\0\0\0\206\2\0\0\2\0\0\0", 12) = 12
or when using strace -x (print in hex) it becomes
Code:

write(3, "\x0c\x00\x00\x00\x86\x02\x00\x00\x02\x00\x00\x00", 12) = 12
In your output the line is
write(3, "\f\0\0\0\211\2\0\0d\0\0\0", 12) = 12
ASCII code for 'd' is 100 so it makes some sense. The beginning is perhaps some version handshake or structure size or something.

rm_you 2008-01-11 10:04

Re: Worse brightness setttings than OS2007
 
Ok, so all I have to do is write out to "/tmp/dsmesock" something like this?
Code:

\x0c\x00\x00\x00\x86\x02\x00\x00\x[hexvalue]\x00\x00\x00
Possibly? >_> I will do some testing.

By the way, what did your strace command line look like? On my n800 it is complicated a little bit because strace doesn't exist in the chroot with dsmetest, so I had to do
Code:

strace -f chroot /mnt/initfs/ dsmetest -l 100

fanoush 2008-01-11 10:15

Re: Worse brightness setttings than OS2007
 
Quote:

Originally Posted by rm_you (Post 125340)
Ok, so all I have to do is write out to "/tmp/dsmesock" something like this?
Code:

\x0c\x00\x00\x00\x86\x02\x00\x00\x[hexvalue]\x00\x00\x00
Possibly?

Yes, not sure about the \x86 since you have different value there.

Quote:

Originally Posted by rm_you (Post 125340)
By the way, what did your strace command line look like?

The line is above, I have compiled static version of strace and copied it to initfs so I could run it inside chroot :-) Maybe there is easier solution but this worked too and I needed it quite a few times inside initfs (like when debugging why dropbear does not start early in usb network recovery mode :-).

rm_you 2008-01-11 10:33

Re: Worse brightness setttings than OS2007
 
Err, yes... I guess I saw that and it didn't register. I guess I will have to compile something similar to get info...

Edit: Ok, so here is the code I am trying to use...
Code:

#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/un.h>

void main()
{
        int mysock = socket(PF_FILE, SOCK_STREAM, 0);
        struct sockaddr_un name;
        size_t size;
        int nbytes;

        name.sun_family = AF_FILE;
        strcpy (name.sun_path, "/mnt/initfs/tmp/dsmesock");
        size = (offsetof (struct sockaddr_un, sun_path) + strlen (name.sun_path) + 1);

        if (connect (mysock, (struct sockaddr *) &name, size) < 0) {
                printf("Error opening socket.\n");
        }
        else {
                nbytes = write (mysock, "\f\0\0\0\211\2\0\0d\0\0\0", 12);
                if (nbytes < 0)
                {
                        printf("Write error.\n");
                        exit(1);
                }
                shutdown(mysock,2);
        }
}

It seems to go? but it doesn't do anything. :(

strace:
Code:

Nezumi:~# strace -f ./testdsme
execve("./testdsme", ["./testdsme"], [/* 59 vars */]) = 0
brk(0)                                  = 0x11000
uname({sys="Linux", node="Nezumi", ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40000000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=31704, ...}) = 0
mmap2(NULL, 31704, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40004000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\324\302"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1086428, ...}) = 0
mmap2(0x41028000, 1118708, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x41028000
mprotect(0x4112c000, 32768, PROT_NONE)  = 0
mmap2(0x41134000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x104) = 0x41134000
mmap2(0x41137000, 8692, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x41137000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000c000
syscall_983045(0x4000c4a0, 0x4000c4a0, 0x41023048, 0x4000cb78, 0x40, 0, 0x48, 0xf0005, 0, 0, 0x41023000, 0xbee853d4, 0, 0xbee85050, 0xfffffff8, 0x41000ad0, 0x20000010, 0x4000c4a0, 0xd02c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) = 0
mprotect(0x41134000, 4096, PROT_READ)  = 0
munmap(0x40004000, 31704)              = 0
mq_notify(1, ptrace: umoven: Input/output error
{...})                    = 3
SYS_283(0x3, 0xbee854d8, 0x1b, 0xbee854d8, 0x41022db8) = 0
write(3, "\f\0\0\0\211\2\0\2\0\0\0\0", 12) = 12
SYS_293(0x3, 0x2, 0xc, 0xc, 0x41022db8) = 0
io_submit(0, 0, 0 <unfinished ... exit status 0>
Process 3339 detached


fanoush 2008-01-11 12:49

Re: Worse brightness setttings than OS2007
 
Maybe using hex values could confuse you or compiler less (i.e. maybe the output on screen look same but binary data in string is in fact different)?

Also if it still doesn't work you could steal the code from https://garage.maemo.org/plugins/scm...ot=powerlaunch
see dsme.c and .h, void dsme_connect(Powered *server) has slightly different socket setup.

EDIT:
also you may try to drop unneeded /mnt/initfs/ from path to dsme socket but that perhaps won't fix anything

rm_you 2008-01-11 22:30

Re: Worse brightness setttings than OS2007
 
Wow, yeah... They've done ALL the work for this. They actually even have a display brightness function. >_>

I'm going to start ripping the code I need from their stuff and converting it to work correctly in my applet. I <3 GPL! :)

rm_you 2008-01-12 13:43

Re: Worse brightness setttings than OS2007
 
Ok, well... I decided to just cheat and use system() to run chroot and dsmetest. It's a little laggier than it would probably be if I implimented it myself in C, but it *works* for now.

I will continue trying to get the socket connections and stuff to work in the next day or two. Meanwhile, the newest version of the applet does *not* require a modified kernel, and can be found here: http://cs.trinity.edu/~acm/debs/adva...ht-0.4b.tar.gz
And source: http://cs.trinity.edu/~acm/debs/adva....4b-src.tar.gz

To install, just untar, cd into the directory and run ./install.sh as root (though it should try to auto gainroot itself... thanks for the code for that, fanoush :P).

Note: I'm not sure why, but it seems that when you first add it and enable it, the UIdesktop crashes. Sometimes this happens the first two times you enable/disable it. I have not been able to determine WHY. If anyone has ideas, please share them.

GeneralAntilles 2008-01-12 19:17

Re: Worse brightness setttings than OS2007
 
Quote:

Originally Posted by rm_you (Post 126122)
Note: I'm not sure why, but it seems that when you first add it and enable it, the UI desktop crashes. Sometimes this happens the first two times you enable/disable it. I have not been able to determine WHY. If anyone has ideas, please share them.

Just for accuracy's sake.

Gurney 2008-01-26 13:49

Re: Worse brightness setttings than OS2007
 
rm_you,

Huge, huge thanks for your work!
Just checked your page and found a v0.5 deb package for your applet. I installed it using the red pill mode, enabled it in the status bar... And here I go. Works like a charm.

No I can use my N800 as a real bedside alarm clock with the dim light at its very minimum. Awesome.

Thanks a lot!

Oh, next step: if it could somehow remind the settnigs wether the unit is plugged or not, that would be, well, just perfect...

Cheers!

GeneralAntilles 2008-01-26 16:00

Re: Worse brightness setttings than OS2007
 
Quote:

Originally Posted by Gurney (Post 133993)
I installed it using the red pill mode . . .

This is not a necessary nor recommended step.

qwerty12 2008-01-26 16:45

Re: Worse brightness setttings than OS2007
 
Quote:

Originally Posted by GeneralAntilles (Post 134025)
This is not a necessary nor recommended step.

In red pill it says , "incompatible". I guess I just have to dpkg it.

@fanoush

Thanks for the link to powerlaunch, I love it :D

@rm_you

Thank you for this but could you please (if possible) add a link to display settings like the original applet.

Either way, thanks for a great program.

rm_you 2008-01-27 08:41

Re: Worse brightness setttings than OS2007
 
Yes, the link for the 0.5 deb can also be found along with a tar.gz of the source at https://garage.maemo.org/frs/?group_id=564

I've had to take a break from Maemo in general due to... personal issues recently. Hopefully I will be back at it sometime soon. Meanwhile, if anyone else wants to make improvements, I'd be happy to include patches / etc. Sorry the SVN isn't set up, but I haven't had time recently to do even *that*.

Anyway, I hope you continue to find the program useful! :)

ericbsmith 2008-01-28 02:26

Re: Worse brightness setttings than OS2007
 
Quote:

Originally Posted by rm_you (Post 134293)
Anyway, I hope you continue to find the program useful! :)

Very useful, thank you.

I tried installing it from the .deb and couldn't, then went into red pill mode and it installed fine. It works great, the only problem I see is that after rebooting the icon on the "taskbar" always shows full brightness, at least until you open the applet and adjust the brightness, then it will report the current state correctly.


All times are GMT. The time now is 16:33.

vBulletin® Version 3.8.8