Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
5ab9c049
Commit
5ab9c049
authored
Apr 02, 2002
by
Dave Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] sonypi driver update from 2.4
parent
94a0b03c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
48 deletions
+145
-48
Documentation/sonypi.txt
Documentation/sonypi.txt
+2
-1
drivers/char/sonypi.c
drivers/char/sonypi.c
+107
-33
drivers/char/sonypi.h
drivers/char/sonypi.h
+16
-11
include/linux/sonypi.h
include/linux/sonypi.h
+20
-3
No files found.
Documentation/sonypi.txt
View file @
5ab9c049
...
...
@@ -25,7 +25,8 @@ A simple daemon which translates the jogdial movements into mouse wheel events
can be downloaded at: <http://www.alcove-labs.org/en/software/sonypi/>
This driver supports also some ioctl commands for setting the LCD screen
brightness (some more commands may be added in the future).
brightness and querying the batteries charge information (some more
commands may be added in the future).
This driver can also be used to set the camera controls on Picturebook series
(brightness, contrast etc), and is used by the video4linux driver for the
...
...
drivers/char/sonypi.c
View file @
5ab9c049
...
...
@@ -109,25 +109,29 @@ static inline int sonypi_emptyq(void) {
return
result
;
}
static
void
sonypi_ecrset
(
u
16
addr
,
u16
value
)
{
wait_on_command
(
1
,
in
w
_p
(
SONYPI_CST_IOPORT
)
&
3
);
out
w
_p
(
0x81
,
SONYPI_CST_IOPORT
);
wait_on_command
(
0
,
in
w
_p
(
SONYPI_CST_IOPORT
)
&
2
);
out
w
_p
(
addr
,
SONYPI_DATA_IOPORT
);
wait_on_command
(
0
,
in
w
_p
(
SONYPI_CST_IOPORT
)
&
2
);
out
w
_p
(
value
,
SONYPI_DATA_IOPORT
);
wait_on_command
(
0
,
in
w
_p
(
SONYPI_CST_IOPORT
)
&
2
);
static
void
sonypi_ecrset
(
u
8
addr
,
u8
value
)
{
wait_on_command
(
1
,
in
b
_p
(
SONYPI_CST_IOPORT
)
&
3
);
out
b
_p
(
0x81
,
SONYPI_CST_IOPORT
);
wait_on_command
(
0
,
in
b
_p
(
SONYPI_CST_IOPORT
)
&
2
);
out
b
_p
(
addr
,
SONYPI_DATA_IOPORT
);
wait_on_command
(
0
,
in
b
_p
(
SONYPI_CST_IOPORT
)
&
2
);
out
b
_p
(
value
,
SONYPI_DATA_IOPORT
);
wait_on_command
(
0
,
in
b
_p
(
SONYPI_CST_IOPORT
)
&
2
);
}
static
u16
sonypi_ecrget
(
u16
addr
)
{
static
u8
sonypi_ecrget
(
u8
addr
)
{
wait_on_command
(
1
,
inb_p
(
SONYPI_CST_IOPORT
)
&
3
);
outb_p
(
0x80
,
SONYPI_CST_IOPORT
);
wait_on_command
(
0
,
inb_p
(
SONYPI_CST_IOPORT
)
&
2
);
outb_p
(
addr
,
SONYPI_DATA_IOPORT
);
wait_on_command
(
0
,
inb_p
(
SONYPI_CST_IOPORT
)
&
2
);
return
inb_p
(
SONYPI_DATA_IOPORT
);
}
wait_on_command
(
1
,
inw_p
(
SONYPI_CST_IOPORT
)
&
3
);
outw_p
(
0x80
,
SONYPI_CST_IOPORT
);
wait_on_command
(
0
,
inw_p
(
SONYPI_CST_IOPORT
)
&
2
);
outw_p
(
addr
,
SONYPI_DATA_IOPORT
);
wait_on_command
(
0
,
inw_p
(
SONYPI_CST_IOPORT
)
&
2
);
return
inw_p
(
SONYPI_DATA_IOPORT
);
static
u16
sonypi_ecrget16
(
u8
addr
)
{
return
sonypi_ecrget
(
addr
)
|
(
sonypi_ecrget
(
addr
+
1
)
<<
8
);
}
/* Initializes the device - this comes from the AML code in the ACPI bios */
...
...
@@ -286,19 +290,38 @@ static void sonypi_camera_on(void) {
sonypi_device
.
camera_power
=
1
;
}
/* sets the bluetooth subsystem power state */
static
void
sonypi_setbluetoothpower
(
u8
state
)
{
state
=
(
state
!=
0
);
if
(
sonypi_device
.
bluetooth_power
&&
state
)
return
;
if
(
!
sonypi_device
.
bluetooth_power
&&
!
state
)
return
;
sonypi_call2
(
0x96
,
state
);
sonypi_call1
(
0x93
);
sonypi_device
.
bluetooth_power
=
state
;
}
/* Interrupt handler: some event is available */
void
sonypi_irq
(
int
irq
,
void
*
dev_id
,
struct
pt_regs
*
regs
)
{
u8
v1
,
v2
,
event
=
0
;
int
i
;
u8
sonypi_jogger_ev
,
sonypi_fnkey_ev
;
u8
sonypi_capture_ev
,
sonypi_bluetooth_ev
;
if
(
sonypi_device
.
model
==
SONYPI_DEVICE_MODEL_TYPE2
)
{
sonypi_jogger_ev
=
SONYPI_TYPE2_JOGGER_EV
;
sonypi_fnkey_ev
=
SONYPI_TYPE2_FNKEY_EV
;
sonypi_capture_ev
=
SONYPI_TYPE2_CAPTURE_EV
;
sonypi_bluetooth_ev
=
SONYPI_TYPE2_BLUETOOTH_EV
;
}
else
{
sonypi_jogger_ev
=
SONYPI_TYPE1_JOGGER_EV
;
sonypi_fnkey_ev
=
SONYPI_TYPE1_FNKEY_EV
;
sonypi_capture_ev
=
SONYPI_TYPE1_CAPTURE_EV
;
sonypi_bluetooth_ev
=
SONYPI_TYPE1_BLUETOOTH_EV
;
}
v1
=
inb_p
(
sonypi_device
.
ioport1
);
...
...
@@ -318,7 +341,7 @@ void sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) {
goto
found
;
}
}
if
((
v2
&
SONYPI_CAPTURE_EV
)
==
SONYPI_CAPTURE_EV
)
{
if
((
v2
&
sonypi_capture_ev
)
==
sonypi_capture_ev
)
{
for
(
i
=
0
;
sonypi_captureev
[
i
].
event
;
i
++
)
if
(
sonypi_captureev
[
i
].
data
==
v1
)
{
event
=
sonypi_captureev
[
i
].
event
;
...
...
@@ -332,7 +355,7 @@ void sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) {
goto
found
;
}
}
if
((
v2
&
SONYPI_BLUETOOTH_EV
)
==
SONYPI_BLUETOOTH_EV
)
{
if
((
v2
&
sonypi_bluetooth_ev
)
==
sonypi_bluetooth_ev
)
{
for
(
i
=
0
;
sonypi_blueev
[
i
].
event
;
i
++
)
if
(
sonypi_blueev
[
i
].
data
==
v1
)
{
event
=
sonypi_blueev
[
i
].
event
;
...
...
@@ -510,24 +533,74 @@ static unsigned int sonypi_misc_poll(struct file *file, poll_table * wait) {
static
int
sonypi_misc_ioctl
(
struct
inode
*
ip
,
struct
file
*
fp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
int
ret
=
0
;
u8
val
;
u8
val8
;
u16
val16
;
down
(
&
sonypi_device
.
lock
);
switch
(
cmd
)
{
case
SONYPI_IOCGBRT
:
val
=
sonypi_ecrget
(
0x96
)
&
0xff
;
if
(
copy_to_user
((
u8
*
)
arg
,
&
val
,
sizeof
(
val
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCSBRT
:
if
(
copy_from_user
(
&
val
,
(
u8
*
)
arg
,
sizeof
(
val
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
sonypi_ecrset
(
0x96
,
val
);
break
;
case
SONYPI_IOCGBRT
:
val8
=
sonypi_ecrget
(
0x96
);
if
(
copy_to_user
((
u8
*
)
arg
,
&
val8
,
sizeof
(
val8
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCSBRT
:
if
(
copy_from_user
(
&
val8
,
(
u8
*
)
arg
,
sizeof
(
val8
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
sonypi_ecrset
(
0x96
,
val8
);
break
;
case
SONYPI_IOCGBAT1CAP
:
val16
=
sonypi_ecrget16
(
0xb2
);
if
(
copy_to_user
((
u16
*
)
arg
,
&
val16
,
sizeof
(
val16
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCGBAT1REM
:
val16
=
sonypi_ecrget16
(
0xa2
);
if
(
copy_to_user
((
u16
*
)
arg
,
&
val16
,
sizeof
(
val16
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCGBAT2CAP
:
val16
=
sonypi_ecrget16
(
0xba
);
if
(
copy_to_user
((
u16
*
)
arg
,
&
val16
,
sizeof
(
val16
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCGBAT2REM
:
val16
=
sonypi_ecrget16
(
0xaa
);
if
(
copy_to_user
((
u16
*
)
arg
,
&
val16
,
sizeof
(
val16
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCGBATFLAGS
:
val8
=
sonypi_ecrget
(
0x81
)
&
0x07
;
if
(
copy_to_user
((
u8
*
)
arg
,
&
val8
,
sizeof
(
val8
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCGBLUE
:
val8
=
sonypi_device
.
bluetooth_power
;
if
(
copy_to_user
((
u8
*
)
arg
,
&
val8
,
sizeof
(
val8
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
break
;
case
SONYPI_IOCSBLUE
:
if
(
copy_from_user
(
&
val8
,
(
u8
*
)
arg
,
sizeof
(
val8
)))
{
ret
=
-
EFAULT
;
goto
out
;
}
sonypi_setbluetoothpower
(
val8
);
break
;
default:
ret
=
-
EINVAL
;
}
...
...
@@ -562,6 +635,7 @@ static int __devinit sonypi_probe(struct pci_dev *pcidev) {
sonypi_device
.
model
=
SONYPI_DEVICE_MODEL_TYPE2
;
sonypi_initq
();
init_MUTEX
(
&
sonypi_device
.
lock
);
sonypi_device
.
bluetooth_power
=
0
;
if
(
pcidev
&&
pci_enable_device
(
pcidev
))
{
printk
(
KERN_ERR
"sonypi: pci_enable_device failed
\n
"
);
...
...
drivers/char/sonypi.h
View file @
5ab9c049
...
...
@@ -34,8 +34,8 @@
#ifdef __KERNEL__
#define SONYPI_DRIVER_MAJORVERSION 1
#define SONYPI_DRIVER_MINORVERSION
8
#define SONYPI_DRIVER_MAJORVERSION
1
#define SONYPI_DRIVER_MINORVERSION
10
#include <linux/types.h>
#include <linux/pci.h>
...
...
@@ -132,15 +132,17 @@ static struct sonypi_irq_list sonypi_type2_irq_list[] = {
#define SONYPI_CAMERA_ROMVERSION 9
/* key press event data (ioport2) */
#define SONYPI_TYPE1_JOGGER_EV 0x10
#define SONYPI_TYPE2_JOGGER_EV 0x08
#define SONYPI_CAPTURE_EV 0x60
#define SONYPI_TYPE1_FNKEY_EV 0x20
#define SONYPI_TYPE2_FNKEY_EV 0x08
#define SONYPI_BLUETOOTH_EV 0x30
#define SONYPI_TYPE1_PKEY_EV 0x40
#define SONYPI_BACK_EV 0x08
#define SONYPI_LID_EV 0x38
#define SONYPI_TYPE1_JOGGER_EV 0x10
#define SONYPI_TYPE2_JOGGER_EV 0x08
#define SONYPI_TYPE1_CAPTURE_EV 0x60
#define SONYPI_TYPE2_CAPTURE_EV 0x08
#define SONYPI_TYPE1_FNKEY_EV 0x20
#define SONYPI_TYPE2_FNKEY_EV 0x08
#define SONYPI_TYPE1_BLUETOOTH_EV 0x30
#define SONYPI_TYPE2_BLUETOOTH_EV 0x08
#define SONYPI_TYPE1_PKEY_EV 0x40
#define SONYPI_BACK_EV 0x08
#define SONYPI_LID_EV 0x38
struct
sonypi_event
{
u8
data
;
...
...
@@ -203,6 +205,8 @@ static struct sonypi_event sonypi_pkeyev[] = {
/* The set of possible bluetooth events */
static
struct
sonypi_event
sonypi_blueev
[]
=
{
{
0x55
,
SONYPI_EVENT_BLUETOOTH_PRESSED
},
{
0x59
,
SONYPI_EVENT_BLUETOOTH_ON
},
{
0x5a
,
SONYPI_EVENT_BLUETOOTH_OFF
},
{
0x00
,
0x00
}
};
...
...
@@ -241,6 +245,7 @@ struct sonypi_device {
u16
ioport2
;
u16
region_size
;
int
camera_power
;
int
bluetooth_power
;
struct
semaphore
lock
;
struct
sonypi_queue
queue
;
int
open_count
;
...
...
include/linux/sonypi.h
View file @
5ab9c049
...
...
@@ -73,11 +73,28 @@
#define SONYPI_EVENT_BACK_PRESSED 35
#define SONYPI_EVENT_LID_CLOSED 36
#define SONYPI_EVENT_LID_OPENED 37
#define SONYPI_EVENT_BLUETOOTH_ON 38
#define SONYPI_EVENT_BLUETOOTH_OFF 39
/* get/set brightness */
#define SONYPI_IOCGBRT _IOR('v', 0, __u8)
#define SONYPI_IOCSBRT _IOW('v', 0, __u8)
/* brightness etc. ioctls */
#define SONYPI_IOCGBRT _IOR('v', 0, __u8)
#define SONYPI_IOCSBRT _IOW('v', 0, __u8)
/* get battery full capacity/remaining capacity */
#define SONYPI_IOCGBAT1CAP _IOR('v', 2, __u16)
#define SONYPI_IOCGBAT1REM _IOR('v', 3, __u16)
#define SONYPI_IOCGBAT2CAP _IOR('v', 4, __u16)
#define SONYPI_IOCGBAT2REM _IOR('v', 5, __u16)
/* get battery flags: battery1/battery2/ac adapter present */
#define SONYPI_BFLAGS_B1 0x01
#define SONYPI_BFLAGS_B2 0x02
#define SONYPI_BFLAGS_AC 0x04
#define SONYPI_IOCGBATFLAGS _IOR('v', 7, __u8)
/* get/set bluetooth subsystem state on/off */
#define SONYPI_IOCGBLUE _IOR('v', 8, __u8)
#define SONYPI_IOCSBLUE _IOW('v', 9, __u8)
#ifdef __KERNEL__
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment