Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UserConfig
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
UserConfig
Commits
ed71df40
Commit
ed71df40
authored
5 years ago
by
JiriKalvoda
Browse files
Options
Downloads
Patches
Plain Diff
LIGHT Add support for second graphic card.
parent
77e394dc
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
light/adr.h
+6
-0
6 additions, 0 deletions
light/adr.h
light/light.c
+56
-46
56 additions, 46 deletions
light/light.c
light/lightInfo.c
+21
-11
21 additions, 11 deletions
light/lightInfo.c
with
83 additions
and
57 deletions
light/adr.h
0 → 100644
+
6
−
0
View file @
ed71df40
const
int
adrlen
=
2
;
const
char
adr
[
adrlen
][
1000
]
=
{
"/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness"
,
"/sys/devices/pci0000:00/0000:00:02.0/drm/card1/card1-eDP-1/intel_backlight/brightness"
};
This diff is collapsed.
Click to expand it.
light/light.c
+
56
−
46
View file @
ed71df40
...
...
@@ -3,17 +3,21 @@
#include
<sys/types.h>
#include
<unistd.h>
#include
<math.h>
#include
"adr.h"
const
char
adr
[]
=
"/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness"
;
const
int
lightMin
=
2
;
const
int
lightMax
=
937
;
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
2
)
return
100
;
setuid
(
0
);
for
(
int
adri
=
0
;
adri
<
adrlen
;
adri
++
)
{
{
if
(
argv
[
1
][
0
]
==
'H'
)
{
FILE
*
f
=
fopen
(
adr
,
"w"
);
FILE
*
f
=
fopen
(
adr
[
adri
],
"w"
);
if
(
!
f
)
goto
nextAdr
;
fprintf
(
f
,
"%d"
,
atoi
(
argv
[
2
]));
fclose
(
f
);
return
0
;
...
...
@@ -24,7 +28,9 @@ int main(int argc,char ** argv)
light
=
argv2
;
else
{
FILE
*
f
=
fopen
(
adr
,
"r"
);
FILE
*
f
=
fopen
(
adr
[
adri
],
"r"
);
if
(
!
f
)
goto
nextAdr
;
fprintf
(
f
,
"%d"
,
atoi
(
argv
[
2
]));
int
realAct
;
fscanf
(
f
,
"%d"
,
&
realAct
);
if
(
realAct
<
light
)
realAct
=
lightMin
;
...
...
@@ -50,7 +56,8 @@ int main(int argc,char ** argv)
notInLimit
=
1
;
}
int
intLight
=
realLight
+
0
.
7
;
FILE
*
f
=
fopen
(
adr
,
"w"
);
FILE
*
f
=
fopen
(
adr
[
adri
],
"w"
);
if
(
!
f
)
goto
nextAdr
;
//printf("light=%d\n",intLight);
fprintf
(
f
,
"%d"
,
intLight
);
fclose
(
f
);
...
...
@@ -59,3 +66,6 @@ int main(int argc,char ** argv)
//system(exe);
return
notInLimit
;
}
nextAdr:
;
}
}
This diff is collapsed.
Click to expand it.
light/lightInfo.c
+
21
−
11
View file @
ed71df40
...
...
@@ -3,14 +3,18 @@
#include
<sys/types.h>
#include
<unistd.h>
#include
<math.h>
#include
"adr.h"
const
char
adr
[]
=
"/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness"
;
const
int
lightMin
=
2
;
const
int
lightMax
=
937
;
int
main
(
int
argc
,
char
**
argv
)
{
setuid
(
0
);
FILE
*
f
=
fopen
(
adr
,
"r"
);
for
(
int
adri
=
0
;
adri
<
adrlen
;
adri
++
)
{
{
FILE
*
f
=
fopen
(
adr
[
adri
],
"r"
);
if
(
!
f
)
goto
nextAdr
;
int
realAct
;
fscanf
(
f
,
"%d"
,
&
realAct
);
double
act
=
log
(
realAct
);
...
...
@@ -20,4 +24,10 @@ int main(int argc,char ** argv)
printf
(
"%s"
,
act
<
i
?
"−"
:
"+"
);
printf
(
"]"
);
fclose
(
f
);
return
0
;
}
nextAdr:
;
}
return
1
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment