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
Kirill Smelkov
linux
Commits
58c2e6e8
Commit
58c2e6e8
authored
Aug 27, 2002
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
http://gkernel.bkbits.net/net-drivers-2.5
into home.transmeta.com:/home/torvalds/v2.5/linux
parents
ceaade5e
b893e082
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
288 additions
and
288 deletions
+288
-288
drivers/media/video/bt819.c
drivers/media/video/bt819.c
+92
-107
drivers/media/video/bt856.c
drivers/media/video/bt856.c
+71
-41
drivers/media/video/saa7110.c
drivers/media/video/saa7110.c
+125
-140
No files found.
drivers/media/video/bt819.c
View file @
58c2e6e8
...
...
@@ -39,15 +39,32 @@
#include <linux/videodev.h>
#include <linux/i2c
-old
.h>
#include <linux/i2c.h>
#include <linux/video_decoder.h>
#define DEBUG(x) x
/* Debug driver */
/* ----------------------------------------------------------------------- */
static
unsigned
short
normal_i2c
[]
=
{
34
>>
1
,
I2C_CLIENT_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
I2C_CLIENT_END
};
static
unsigned
short
probe
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
probe_range
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
ignore
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
ignore_range
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
force
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
struct
i2c_client_address_data
addr_data
=
{
normal_i2c
,
normal_i2c_range
,
probe
,
probe_range
,
ignore
,
ignore_range
,
force
};
static
struct
i2c_client
client_template
;
struct
bt819
{
struct
i2c_
bus
*
bus
;
struct
i2c_
client
*
client
;
int
addr
;
unsigned
char
reg
[
32
];
...
...
@@ -59,6 +76,7 @@ struct bt819 {
int
contrast
;
int
hue
;
int
sat
;
struct
semaphore
lock
;
};
struct
timing
{
...
...
@@ -82,71 +100,17 @@ struct timing timing_data[] = {
/* ----------------------------------------------------------------------- */
static
int
bt819_write
(
struct
bt819
*
dev
,
unsigned
char
subaddr
,
unsigned
char
data
)
static
int
bt819_probe
(
struct
i2c_adapter
*
adap
)
{
int
ack
;
LOCK_I2C_BUS
(
dev
->
bus
);
i2c_start
(
dev
->
bus
);
i2c_sendbyte
(
dev
->
bus
,
dev
->
addr
,
I2C_DELAY
);
i2c_sendbyte
(
dev
->
bus
,
subaddr
,
I2C_DELAY
);
ack
=
i2c_sendbyte
(
dev
->
bus
,
data
,
I2C_DELAY
);
dev
->
reg
[
subaddr
]
=
data
;
i2c_stop
(
dev
->
bus
);
UNLOCK_I2C_BUS
(
dev
->
bus
);
return
ack
;
return
i2c_probe
(
adap
,
&
addr_data
,
bt819_attach
);
}
static
int
bt819_setbit
(
struct
bt819
*
dev
,
int
subaddr
,
int
bit
,
int
data
)
{
return
bt819_write
(
dev
,
subaddr
,
(
dev
->
reg
[
subaddr
]
&
~
(
1
<<
bit
))
|
(
data
?
(
1
<<
bit
)
:
0
));
}
static
int
bt819_write_block
(
struct
bt819
*
dev
,
unsigned
const
char
*
data
,
unsigned
int
len
)
{
int
ack
;
unsigned
subaddr
;
ack
=
0
;
while
(
len
>
1
)
{
LOCK_I2C_BUS
(
dev
->
bus
);
i2c_start
(
dev
->
bus
);
i2c_sendbyte
(
dev
->
bus
,
dev
->
addr
,
I2C_DELAY
);
ack
=
i2c_sendbyte
(
dev
->
bus
,
(
subaddr
=
*
data
++
),
I2C_DELAY
);
ack
=
i2c_sendbyte
(
dev
->
bus
,
(
dev
->
reg
[
subaddr
]
=
*
data
++
),
I2C_DELAY
);
len
-=
2
;
while
(
len
>
1
&&
*
data
==
++
subaddr
)
{
data
++
;
ack
=
i2c_sendbyte
(
dev
->
bus
,
(
dev
->
reg
[
subaddr
]
=
*
data
++
),
I2C_DELAY
);
len
-=
2
;
}
i2c_stop
(
dev
->
bus
);
UNLOCK_I2C_BUS
(
dev
->
bus
);
}
return
ack
;
return
i2c_smbus_write_byte_data
(
dev
->
client
,
subaddr
,
(
dev
->
reg
[
subaddr
]
&
~
(
1
<<
bit
))
|
(
data
?
(
1
<<
bit
)
:
0
));
}
static
int
bt819_read
(
struct
bt819
*
dev
,
unsigned
char
subaddr
)
{
int
data
;
LOCK_I2C_BUS
(
dev
->
bus
);
i2c_start
(
dev
->
bus
);
i2c_sendbyte
(
dev
->
bus
,
dev
->
addr
,
I2C_DELAY
);
i2c_sendbyte
(
dev
->
bus
,
subaddr
,
I2C_DELAY
);
i2c_start
(
dev
->
bus
);
i2c_sendbyte
(
dev
->
bus
,
dev
->
addr
|
1
,
I2C_DELAY
);
data
=
i2c_readbyte
(
dev
->
bus
,
1
);
i2c_stop
(
dev
->
bus
);
UNLOCK_I2C_BUS
(
dev
->
bus
);
return
data
;
}
static
int
bt819_init
(
struct
i2c_device
*
device
)
static
int
bt819_init
(
struct
i2c_client
*
client
)
{
struct
bt819
*
decoder
;
...
...
@@ -178,7 +142,7 @@ static int bt819_init(struct i2c_device *device)
struct
timing
*
timing
;
decoder
=
device
->
data
;
decoder
=
client
->
data
;
timing
=
&
timing_data
[
decoder
->
norm
];
init
[
3
*
2
-
1
]
=
(((
timing
->
vdelay
>>
8
)
&
0x03
)
<<
6
)
|
...
...
@@ -192,31 +156,38 @@ static int bt819_init(struct i2c_device *device)
init
[
8
*
2
-
1
]
=
timing
->
hscale
>>
8
;
init
[
9
*
2
-
1
]
=
timing
->
hscale
&
0xff
;
bt819_write
(
decoder
,
0x1f
,
0x00
);
i2c_smbus_write_byte_data
(
client
,
0x1f
,
0x00
);
mdelay
(
1
);
return
bt819_write_block
(
decoder
,
init
,
sizeof
(
init
));
return
i2c_master_send
(
client
,
init
,
sizeof
(
init
));
}
/* ----------------------------------------------------------------------- */
static
int
bt819_attach
(
struct
i2c_
device
*
device
)
static
int
bt819_attach
(
struct
i2c_
adapter
*
adap
,
int
addr
,
unsigned
long
flags
,
int
kind
)
{
int
i
;
struct
bt819
*
decoder
;
struct
i2c_client
*
client
;
MOD_INC_USE_COUNT
;
device
->
data
=
decoder
=
kmalloc
(
sizeof
(
struct
bt819
),
GFP_KERNEL
);
client
=
kmalloc
(
sizeof
(
*
client
),
GFP_KERNEL
);
if
(
client
==
NULL
)
return
-
ENOMEM
;
client_template
.
adapter
=
adap
;
client_template
.
addr
=
addr
;
memcpy
(
client
,
&
client_template
,
sizeof
(
*
client
));
decoder
=
kmalloc
(
sizeof
(
struct
bt819
),
GFP_KERNEL
);
if
(
decoder
==
NULL
)
{
MOD_DEC_USE_COUNT
;
return
-
ENOMEM
;
}
memset
(
decoder
,
0
,
sizeof
(
struct
bt819
));
strcpy
(
device
->
name
,
"bt819"
);
decoder
->
bus
=
device
->
bus
;
decoder
->
addr
=
device
->
addr
;
strcpy
(
client
->
name
,
"bt819"
);
client
->
data
=
decoder
;
decoder
->
client
=
client
;
decoder
->
addr
=
addr
;
decoder
->
norm
=
VIDEO_MODE_NTSC
;
decoder
->
input
=
0
;
decoder
->
enable
=
1
;
...
...
@@ -226,34 +197,39 @@ static int bt819_attach(struct i2c_device *device)
decoder
->
sat
=
32768
;
decoder
->
initialized
=
0
;
i
=
bt819_init
(
device
);
i
=
bt819_init
(
client
);
if
(
i
<
0
)
{
printk
(
KERN_ERR
"%s: bt819_attach: init status %d
\n
"
,
decoder
->
bus
->
name
,
i
);
decoder
->
client
->
name
,
i
);
}
else
{
printk
(
KERN_INFO
"%s: bt819_attach: chip version %x
\n
"
,
decoder
->
bus
->
name
,
bt819_read
(
decoder
,
decoder
->
client
->
name
,
i2c_smbus_read_byte_data
(
client
,
0x17
)
&
0x0f
);
}
init_MUTEX
(
&
decoder
->
lock
);
i2c_attach_client
(
client
);
MOD_INC_USE_COUNT
;
return
0
;
}
static
int
bt819_detach
(
struct
i2c_
device
*
device
)
static
int
bt819_detach
(
struct
i2c_
client
*
client
)
{
kfree
(
device
->
data
);
i2c_detach_client
(
client
);
kfree
(
client
->
data
);
kfree
(
client
);
MOD_DEC_USE_COUNT
;
return
0
;
}
static
int
bt819_command
(
struct
i2c_
device
*
device
,
unsigned
int
cmd
,
void
*
arg
)
static
int
bt819_command
(
struct
i2c_
client
*
client
,
unsigned
int
cmd
,
void
*
arg
)
{
int
temp
;
struct
bt819
*
decoder
=
device
->
data
;
struct
bt819
*
decoder
=
client
->
data
;
//return 0;
if
(
!
decoder
->
initialized
)
{
// First call to bt819_init could be
bt819_init
(
device
);
// without #FRST = 0
bt819_init
(
client
);
// without #FRST = 0
decoder
->
initialized
=
1
;
}
...
...
@@ -277,7 +253,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
int
status
;
int
res
;
status
=
bt819_read
(
decoder
,
0x00
);
status
=
i2c_smbus_read_byte_data
(
client
,
0x00
);
res
=
0
;
if
((
status
&
0x80
))
{
res
|=
DECODER_STATUS_GOOD
;
...
...
@@ -302,7 +278,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
*
iarg
=
res
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt819: get status %x
\n
"
,
decoder
->
bus
->
name
,
*
iarg
));
decoder
->
client
->
name
,
*
iarg
));
}
break
;
...
...
@@ -312,37 +288,38 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
struct
timing
*
timing
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt819: set norm %x
\n
"
,
decoder
->
bus
->
name
,
*
iarg
));
decoder
->
client
->
name
,
*
iarg
));
if
(
*
iarg
==
VIDEO_MODE_NTSC
)
{
bt819_setbit
(
decoder
,
0x01
,
0
,
1
);
bt819_setbit
(
decoder
,
0x01
,
1
,
0
);
bt819_write
(
decoder
,
0x18
,
0x68
);
bt819_write
(
decoder
,
0x19
,
0x5d
);
i2c_smbus_write_byte_data
(
client
,
0x18
,
0x68
);
i2c_smbus_write_byte_data
(
client
,
0x19
,
0x5d
);
//bt819_setbit(decoder, 0x1a, 5, 1);
timing
=
&
timing_data
[
VIDEO_MODE_NTSC
];
}
else
{
bt819_setbit
(
decoder
,
0x01
,
0
,
1
);
bt819_setbit
(
decoder
,
0x01
,
1
,
1
);
bt819_write
(
decoder
,
0x18
,
0x7f
);
bt819_write
(
decoder
,
0x19
,
0x72
);
i2c_smbus_write_byte_data
(
client
,
0x18
,
0x7f
);
i2c_smbus_write_byte_data
(
client
,
0x19
,
0x72
);
//bt819_setbit(decoder, 0x1a, 5, 0);
timing
=
&
timing_data
[
VIDEO_MODE_PAL
];
}
bt819_write
(
decoder
,
0x03
,
i2c_smbus_write_byte_data
(
client
,
0x03
,
(((
timing
->
vdelay
>>
8
)
&
0x03
)
<<
6
)
|
(((
timing
->
vactive
>>
8
)
&
0x03
)
<<
4
)
|
(((
timing
->
hdelay
>>
8
)
&
0x03
)
<<
2
)
|
((
timing
->
hactive
>>
8
)
&
0x03
));
bt819_write
(
decoder
,
0x04
,
timing
->
vdelay
&
0xff
);
bt819_write
(
decoder
,
0x05
,
timing
->
vactive
&
0xff
);
bt819_write
(
decoder
,
0x06
,
timing
->
hdelay
&
0xff
);
bt819_write
(
decoder
,
0x07
,
timing
->
hactive
&
0xff
);
bt819_write
(
decoder
,
0x08
,
timing
->
hscale
>>
8
);
bt819_write
(
decoder
,
0x09
,
timing
->
hscale
&
0xff
);
i2c_smbus_write_byte_data
(
client
,
0x04
,
timing
->
vdelay
&
0xff
);
i2c_smbus_write_byte_data
(
client
,
0x05
,
timing
->
vactive
&
0xff
);
i2c_smbus_write_byte_data
(
client
,
0x06
,
timing
->
hdelay
&
0xff
);
i2c_smbus_write_byte_data
(
client
,
0x07
,
timing
->
hactive
&
0xff
);
i2c_smbus_write_byte_data
(
client
,
0x08
,
timing
->
hscale
>>
8
);
i2c_smbus_write_byte_data
(
client
,
0x09
,
timing
->
hscale
&
0xff
);
decoder
->
norm
=
*
iarg
;
}
break
;
...
...
@@ -352,7 +329,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
int
*
iarg
=
arg
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt819: set input %x
\n
"
,
decoder
->
bus
->
name
,
*
iarg
));
decoder
->
client
->
name
,
*
iarg
));
if
(
*
iarg
<
0
||
*
iarg
>
7
)
{
return
-
EINVAL
;
...
...
@@ -377,7 +354,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
int
*
iarg
=
arg
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt819: set output %x
\n
"
,
decoder
->
bus
->
name
,
*
iarg
));
decoder
->
client
->
name
,
*
iarg
));
/* not much choice of outputs */
if
(
*
iarg
!=
0
)
{
...
...
@@ -393,7 +370,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
DEBUG
(
printk
(
KERN_INFO
"%s-bt819: enable output %x
\n
"
,
decoder
->
bus
->
name
,
*
iarg
));
decoder
->
client
->
name
,
*
iarg
));
if
(
decoder
->
enable
!=
enable
)
{
decoder
->
enable
=
enable
;
...
...
@@ -414,21 +391,21 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
DEBUG
(
printk
(
KERN_INFO
"%s-bt819: set picture brightness %d contrast %d colour %d
\n
"
,
decoder
->
bus
->
name
,
pic
->
brightness
,
decoder
->
client
->
name
,
pic
->
brightness
,
pic
->
contrast
,
pic
->
colour
));
if
(
decoder
->
bright
!=
pic
->
brightness
)
{
/* We want -128 to 127 we get 0-65535 */
decoder
->
bright
=
pic
->
brightness
;
bt819_write
(
decoder
,
0x0a
,
i2c_smbus_write_byte_data
(
client
,
0x0a
,
(
decoder
->
bright
>>
8
)
-
128
);
}
if
(
decoder
->
contrast
!=
pic
->
contrast
)
{
/* We want 0 to 511 we get 0-65535 */
decoder
->
contrast
=
pic
->
contrast
;
bt819_write
(
decoder
,
0x0c
,
i2c_smbus_write_byte_data
(
client
,
0x0c
,
(
decoder
->
contrast
>>
7
)
&
0xff
);
bt819_setbit
(
decoder
,
0x0b
,
2
,
...
...
@@ -439,14 +416,14 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
if
(
decoder
->
sat
!=
pic
->
colour
)
{
/* We want 0 to 511 we get 0-65535 */
decoder
->
sat
=
pic
->
colour
;
bt819_write
(
decoder
,
0x0d
,
i2c_smbus_write_byte_data
(
client
,
0x0d
,
(
decoder
->
sat
>>
7
)
&
0xff
);
bt819_setbit
(
decoder
,
0x0b
,
1
,
((
decoder
->
sat
>>
15
)
&
0x01
));
temp
=
(
decoder
->
sat
*
201
)
/
237
;
bt819_write
(
decoder
,
0x0e
,
i2c_smbus_write_byte_data
(
client
,
0x0e
,
(
temp
>>
7
)
&
0xff
);
bt819_setbit
(
decoder
,
0x0b
,
0
,
(
temp
>>
15
)
&
0x01
);
...
...
@@ -455,7 +432,7 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
if
(
decoder
->
hue
!=
pic
->
hue
)
{
/* We want -128 to 127 we get 0-65535 */
decoder
->
hue
=
pic
->
hue
;
bt819_write
(
decoder
,
0x0f
,
i2c_smbus_write_byte_data
(
client
,
0x0f
,
128
-
(
decoder
->
hue
>>
8
));
}
}
...
...
@@ -472,22 +449,30 @@ static int bt819_command(struct i2c_device *device, unsigned int cmd, void *arg)
static
struct
i2c_driver
i2c_driver_bt819
=
{
"bt819"
,
/* name */
I2C_DRIVERID_VIDEODECODER
,
/* ID */
I2C_BT819
,
I2C_BT819
+
1
,
bt819_attach
,
I2C_DRIVERID_BT819
,
/* ID */
I2C_DF_NOTIFY
,
bt819_probe
,
bt819_detach
,
bt819_command
};
static
struct
i2c_client
client_template
=
{
"bt819_client"
,
-
1
,
0
,
0
,
NULL
,
&
i2c_driver_bt819
};
static
int
bt819_setup
(
void
)
{
return
i2c_
register
_driver
(
&
i2c_driver_bt819
);
return
i2c_
add
_driver
(
&
i2c_driver_bt819
);
}
static
void
bt819_exit
(
void
)
{
i2c_
unregister
_driver
(
&
i2c_driver_bt819
);
i2c_
del
_driver
(
&
i2c_driver_bt819
);
}
module_init
(
bt819_setup
);
...
...
drivers/media/video/bt856.c
View file @
58c2e6e8
...
...
@@ -47,15 +47,32 @@
#include <linux/version.h>
#include <asm/uaccess.h>
#include <linux/i2c
-old
.h>
#include <linux/i2c.h>
#include <linux/video_encoder.h>
#define DEBUG(x) x
/* Debug driver */
/* ----------------------------------------------------------------------- */
static
unsigned
short
normal_i2c
[]
=
{
34
>>
1
,
I2C_CLIENT_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
I2C_CLIENT_END
};
static
unsigned
short
probe
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
probe_range
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
ignore
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
ignore_range
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
force
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
struct
i2c_client_address_data
addr_data
=
{
normal_i2c
,
normal_i2c_range
,
probe
,
probe_range
,
ignore
,
ignore_range
,
force
};
static
struct
i2c_client
client_template
;
struct
bt856
{
struct
i2c_
bus
*
bus
;
struct
i2c_
client
*
client
;
int
addr
;
unsigned
char
reg
[
128
];
...
...
@@ -73,40 +90,35 @@ struct bt856 {
/* ----------------------------------------------------------------------- */
static
int
bt856_write
(
struct
bt856
*
dev
,
unsigned
char
subaddr
,
unsigned
char
data
)
static
int
bt856_probe
(
struct
i2c_adapter
*
adap
)
{
int
ack
;
LOCK_I2C_BUS
(
dev
->
bus
);
i2c_start
(
dev
->
bus
);
i2c_sendbyte
(
dev
->
bus
,
dev
->
addr
,
I2C_DELAY
);
i2c_sendbyte
(
dev
->
bus
,
subaddr
,
I2C_DELAY
);
ack
=
i2c_sendbyte
(
dev
->
bus
,
data
,
I2C_DELAY
);
dev
->
reg
[
subaddr
]
=
data
;
i2c_stop
(
dev
->
bus
);
UNLOCK_I2C_BUS
(
dev
->
bus
);
return
ack
;
return
i2c_probe
(
adap
,
&
addr_data
,
bt856_attach
);
}
static
int
bt856_setbit
(
struct
bt856
*
dev
,
int
subaddr
,
int
bit
,
int
data
)
{
return
bt856_write
(
dev
,
subaddr
,(
dev
->
reg
[
subaddr
]
&
~
(
1
<<
bit
))
|
(
data
?
(
1
<<
bit
)
:
0
));
return
i2c_smbus_write_byte_data
(
dev
->
client
,
subaddr
,(
dev
->
reg
[
subaddr
]
&
~
(
1
<<
bit
))
|
(
data
?
(
1
<<
bit
)
:
0
));
}
/* ----------------------------------------------------------------------- */
static
int
bt856_attach
(
struct
i2c_
device
*
device
)
static
int
bt856_attach
(
struct
i2c_
adapter
*
adap
,
int
addr
,
unsigned
long
flags
,
int
kind
)
{
struct
bt856
*
encoder
;
struct
i2c_client
*
client
;
client
=
kmalloc
(
sizeof
(
*
client
),
GFP_KERNEL
);
if
(
client
==
NULL
)
return
-
ENOMEM
;
client_template
.
adapter
=
adap
;
client_template
.
addr
=
addr
;
memcpy
(
client
,
&
client_template
,
sizeof
(
*
client
));
/* This chip is not on the buz card but at the same address saa7185 */
//if (memcmp(device->bus->name, "buz", 3) == 0 || memcmp(device->bus->name, "zr36057", 6) == 0)
// return 1;
MOD_INC_USE_COUNT
;
device
->
data
=
encoder
=
kmalloc
(
sizeof
(
struct
bt856
),
GFP_KERNEL
);
encoder
=
kmalloc
(
sizeof
(
struct
bt856
),
GFP_KERNEL
);
if
(
encoder
==
NULL
)
{
MOD_DEC_USE_COUNT
;
...
...
@@ -115,17 +127,21 @@ static int bt856_attach(struct i2c_device *device)
memset
(
encoder
,
0
,
sizeof
(
struct
bt856
));
strcpy
(
device
->
name
,
"bt856"
);
encoder
->
bus
=
device
->
bus
;
encoder
->
addr
=
device
->
addr
;
strcpy
(
client
->
name
,
"bt856"
);
encoder
->
client
=
client
;
client
->
data
=
encoder
;
encoder
->
addr
=
client
->
addr
;
encoder
->
norm
=
VIDEO_MODE_NTSC
;
encoder
->
enable
=
1
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt856: attach
\n
"
,
encoder
->
bus
->
name
));
bt856_write
(
encoder
,
0xdc
,
0x18
);
bt856_write
(
encoder
,
0xda
,
0
);
bt856_write
(
encoder
,
0xde
,
0
);
i2c_smbus_write_byte_data
(
client
,
0xdc
,
0x18
);
encoder
->
reg
[
0xdc
]
=
0x18
;
i2c_smbus_write_byte_data
(
client
,
0xda
,
0
);
encoder
->
reg
[
0xda
]
=
0
;
i2c_smbus_write_byte_data
(
client
,
0xde
,
0
);
encoder
->
reg
[
0xde
]
=
0
;
bt856_setbit
(
encoder
,
0xdc
,
3
,
1
);
//bt856_setbit(encoder, 0xdc, 6, 0);
...
...
@@ -145,21 +161,26 @@ static int bt856_attach(struct i2c_device *device)
bt856_setbit
(
encoder
,
0xdc
,
1
,
1
);
bt856_setbit
(
encoder
,
0xde
,
4
,
0
);
bt856_setbit
(
encoder
,
0xde
,
3
,
1
);
init_MUTEX
(
&
encoder
->
lock
);
i2c_attach_client
(
client
);
MOD_INC_USE_COUNT
;
return
0
;
}
static
int
bt856_detach
(
struct
i2c_
device
*
device
)
static
int
bt856_detach
(
struct
i2c_
client
*
client
)
{
kfree
(
device
->
data
);
i2c_detach_client
(
client
);
kfree
(
client
->
data
);
kfree
(
client
);
MOD_DEC_USE_COUNT
;
return
0
;
}
static
int
bt856_command
(
struct
i2c_
device
*
device
,
unsigned
int
cmd
,
static
int
bt856_command
(
struct
i2c_
client
*
client
,
unsigned
int
cmd
,
void
*
arg
)
{
struct
bt856
*
encoder
=
device
->
data
;
struct
bt856
*
encoder
=
client
->
data
;
switch
(
cmd
)
{
...
...
@@ -169,7 +190,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
DEBUG
(
printk
(
KERN_INFO
"%s-bt856: get capabilities
\n
"
,
encoder
->
bus
->
name
));
encoder
->
client
->
name
));
cap
->
flags
=
VIDEO_ENCODER_PAL
...
...
@@ -184,7 +205,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
int
*
iarg
=
arg
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt856: set norm %d
\n
"
,
encoder
->
bus
->
name
,
*
iarg
));
encoder
->
client
->
name
,
*
iarg
));
switch
(
*
iarg
)
{
...
...
@@ -211,7 +232,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
int
*
iarg
=
arg
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt856: set input %d
\n
"
,
encoder
->
bus
->
name
,
*
iarg
));
encoder
->
client
->
name
,
*
iarg
));
/* We only have video bus.
*iarg = 0: input is from bt819
...
...
@@ -247,7 +268,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
int
*
iarg
=
arg
;
DEBUG
(
printk
(
KERN_INFO
"%s-bt856: set output %d
\n
"
,
encoder
->
bus
->
name
,
*
iarg
));
encoder
->
client
->
name
,
*
iarg
));
/* not much choice of outputs */
if
(
*
iarg
!=
0
)
{
...
...
@@ -264,7 +285,7 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
DEBUG
(
printk
(
KERN_INFO
"%s-bt856: enable output %d
\n
"
,
encoder
->
bus
->
name
,
encoder
->
enable
));
encoder
->
client
->
name
,
encoder
->
enable
));
}
break
;
...
...
@@ -279,21 +300,30 @@ static int bt856_command(struct i2c_device *device, unsigned int cmd,
static
struct
i2c_driver
i2c_driver_bt856
=
{
"bt856"
,
/* name */
I2C_DRIVERID_
VIDEOENCODER
,
/* ID */
I2C_
BT856
,
I2C_BT856
+
1
,
bt856_
attach
,
I2C_DRIVERID_
BT856
,
/* ID */
I2C_
DF_NOTIFY
,
bt856_
probe
,
bt856_detach
,
bt856_command
};
static
struct
i2c_client
client_template
=
{
"bt856_client"
,
-
1
,
0
,
0
,
NULL
,
&
i2c_driver_bt856
};
static
int
bt856_init
(
void
)
{
return
i2c_
register
_driver
(
&
i2c_driver_bt856
);
return
i2c_
add
_driver
(
&
i2c_driver_bt856
);
}
static
void
bt856_exit
(
void
)
{
i2c_
unregister
_driver
(
&
i2c_driver_bt856
);
i2c_
del
_driver
(
&
i2c_driver_bt856
);
}
module_init
(
bt856_init
);
...
...
drivers/media/video/saa7110.c
View file @
58c2e6e8
...
...
@@ -26,7 +26,7 @@
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/i2c
-old
.h>
#include <linux/i2c.h>
#include <linux/videodev.h>
#include "linux/video_decoder.h"
...
...
@@ -37,13 +37,31 @@
#define I2C_SAA7110 0x9C
/* or 0x9E */
#define IF_NAME "saa7110"
#define I2C_DELAY 10
/* 10 us or 100khz */
static
unsigned
short
normal_i2c
[]
=
{
34
>>
1
,
I2C_CLIENT_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
I2C_CLIENT_END
};
static
unsigned
short
probe
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
probe_range
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
ignore
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
ignore_range
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
unsigned
short
force
[
2
]
=
{
I2C_CLIENT_END
,
I2C_CLIENT_END
};
static
struct
i2c_client_address_data
addr_data
=
{
normal_i2c
,
normal_i2c_range
,
probe
,
probe_range
,
ignore
,
ignore_range
,
force
};
static
struct
i2c_client
client_template
;
struct
saa7110
{
struct
i2c_bus
*
bus
;
struct
i2c_client
*
client
;
int
addr
;
unsigned
char
reg
[
36
];
struct
semaphore
lock
;
int
norm
;
int
input
;
int
enable
;
...
...
@@ -53,68 +71,11 @@ struct saa7110 {
int
sat
;
};
/* ----------------------------------------------------------------------- */
/* I2C support functions */
/* ----------------------------------------------------------------------- */
static
int
saa7110_write
(
struct
saa7110
*
decoder
,
unsigned
char
subaddr
,
unsigned
char
data
)
{
int
ack
;
LOCK_I2C_BUS
(
decoder
->
bus
);
i2c_start
(
decoder
->
bus
);
i2c_sendbyte
(
decoder
->
bus
,
decoder
->
addr
,
I2C_DELAY
);
i2c_sendbyte
(
decoder
->
bus
,
subaddr
,
I2C_DELAY
);
ack
=
i2c_sendbyte
(
decoder
->
bus
,
data
,
I2C_DELAY
);
i2c_stop
(
decoder
->
bus
);
decoder
->
reg
[
subaddr
]
=
data
;
UNLOCK_I2C_BUS
(
decoder
->
bus
);
return
ack
;
}
static
int
saa7110_write_block
(
struct
saa7110
*
decoder
,
unsigned
const
char
*
data
,
unsigned
int
len
)
{
unsigned
subaddr
=
*
data
;
LOCK_I2C_BUS
(
decoder
->
bus
);
i2c_start
(
decoder
->
bus
);
i2c_sendbyte
(
decoder
->
bus
,
decoder
->
addr
,
I2C_DELAY
);
while
(
len
--
>
0
)
{
if
(
i2c_sendbyte
(
decoder
->
bus
,
*
data
,
0
))
{
i2c_stop
(
decoder
->
bus
);
UNLOCK_I2C_BUS
(
decoder
->
bus
);
return
-
EAGAIN
;
}
decoder
->
reg
[
subaddr
++
]
=
*
data
++
;
}
i2c_stop
(
decoder
->
bus
);
UNLOCK_I2C_BUS
(
decoder
->
bus
);
return
0
;
}
static
int
saa7110_read
(
struct
saa7110
*
decoder
)
{
int
data
;
LOCK_I2C_BUS
(
decoder
->
bus
);
i2c_start
(
decoder
->
bus
);
i2c_sendbyte
(
decoder
->
bus
,
decoder
->
addr
,
I2C_DELAY
);
i2c_start
(
decoder
->
bus
);
i2c_sendbyte
(
decoder
->
bus
,
decoder
->
addr
|
1
,
I2C_DELAY
);
data
=
i2c_readbyte
(
decoder
->
bus
,
1
);
i2c_stop
(
decoder
->
bus
);
UNLOCK_I2C_BUS
(
decoder
->
bus
);
return
data
;
}
/* ----------------------------------------------------------------------- */
/* SAA7110 functions */
/* ----------------------------------------------------------------------- */
static
int
saa7110_selmux
(
struct
i2c_
device
*
device
,
int
chan
)
int
saa7110_selmux
(
struct
i2c_
client
*
client
,
int
chan
)
{
static
const
unsigned
char
modes
[
9
][
8
]
=
{
/* mode 0 */
{
0x00
,
0xD9
,
0x17
,
0x40
,
0x03
,
0x44
,
0x75
,
0x16
},
...
...
@@ -126,61 +87,59 @@ static const unsigned char modes[9][8] = {
/* mode 6 */
{
0x80
,
0x59
,
0x17
,
0x42
,
0xA3
,
0x44
,
0x75
,
0x12
},
/* mode 7 */
{
0x80
,
0x9A
,
0x17
,
0xB1
,
0x13
,
0x60
,
0xB5
,
0x14
},
/* mode 8 */
{
0x80
,
0x3C
,
0x27
,
0xC1
,
0x23
,
0x44
,
0x75
,
0x21
}
};
struct
saa7110
*
decoder
=
device
->
data
;
const
unsigned
char
*
ptr
=
modes
[
chan
];
saa7110_write
(
decoder
,
0x06
,
ptr
[
0
]);
/* Luminance control */
saa7110_write
(
decoder
,
0x20
,
ptr
[
1
]);
/* Analog Control #1 */
saa7110_write
(
decoder
,
0x21
,
ptr
[
2
]);
/* Analog Control #2 */
saa7110_write
(
decoder
,
0x22
,
ptr
[
3
]);
/* Mixer Control #1 */
saa7110_write
(
decoder
,
0x2C
,
ptr
[
4
]);
/* Mixer Control #2 */
saa7110_write
(
decoder
,
0x30
,
ptr
[
5
]);
/* ADCs gain control */
saa7110_write
(
decoder
,
0x31
,
ptr
[
6
]);
/* Mixer Control #3 */
saa7110_write
(
decoder
,
0x21
,
ptr
[
7
]);
/* Analog Control #2 */
i2c_smbus_write_byte_data
(
client
,
0x06
,
ptr
[
0
]);
/* Luminance control */
i2c_smbus_write_byte_data
(
client
,
0x20
,
ptr
[
1
]);
/* Analog Control #1 */
i2c_smbus_write_byte_data
(
client
,
0x21
,
ptr
[
2
]);
/* Analog Control #2 */
i2c_smbus_write_byte_data
(
client
,
0x22
,
ptr
[
3
]);
/* Mixer Control #1 */
i2c_smbus_write_byte_data
(
client
,
0x2C
,
ptr
[
4
]);
/* Mixer Control #2 */
i2c_smbus_write_byte_data
(
client
,
0x30
,
ptr
[
5
]);
/* ADCs gain control */
i2c_smbus_write_byte_data
(
client
,
0x31
,
ptr
[
6
]);
/* Mixer Control #3 */
i2c_smbus_write_byte_data
(
client
,
0x21
,
ptr
[
7
]);
/* Analog Control #2 */
return
0
;
}
static
int
determine_norm
(
struct
i2c_
device
*
dev
)
int
determine_norm
(
struct
i2c_
client
*
client
)
{
struct
saa7110
*
decoder
=
dev
->
data
;
int
status
;
/* mode changed, start automatic detection */
status
=
saa7110_read
(
decoder
);
status
=
i2c_smbus_read_byte
(
client
);
if
((
status
&
3
)
==
0
)
{
saa7110_write
(
decoder
,
0x06
,
0x80
);
i2c_smbus_write_byte_data
(
client
,
0x06
,
0x80
);
if
(
status
&
0x20
)
{
DEBUG
(
printk
(
KERN_INFO
"%s: norm=bw60
\n
"
,
dev
->
name
));
saa7110_write
(
decoder
,
0x2E
,
0x81
);
DEBUG
(
printk
(
KERN_INFO
"%s: norm=bw60
\n
"
,
adp
->
name
));
i2c_smbus_write_byte_data
(
client
,
0x2E
,
0x81
);
return
VIDEO_MODE_NTSC
;
}
DEBUG
(
printk
(
KERN_INFO
"%s: norm=bw50
\n
"
,
dev
->
name
));
saa7110_write
(
decoder
,
0x2E
,
0x9A
);
DEBUG
(
printk
(
KERN_INFO
"%s: norm=bw50
\n
"
,
adp
->
name
));
i2c_smbus_write_byte_data
(
client
,
0x2E
,
0x9A
);
return
VIDEO_MODE_PAL
;
}
saa7110_write
(
decoder
,
0x06
,
0x00
);
i2c_smbus_write_byte_data
(
client
,
0x06
,
0x00
);
if
(
status
&
0x20
)
{
/* 60Hz */
DEBUG
(
printk
(
KERN_INFO
"%s: norm=ntsc
\n
"
,
dev
->
name
));
saa7110_write
(
decoder
,
0x0D
,
0x06
);
saa7110_write
(
decoder
,
0x11
,
0x2C
);
saa7110_write
(
decoder
,
0x2E
,
0x81
);
DEBUG
(
printk
(
KERN_INFO
"%s: norm=ntsc
\n
"
,
adp
->
name
));
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x06
);
i2c_smbus_write_byte_data
(
client
,
0x11
,
0x2C
);
i2c_smbus_write_byte_data
(
client
,
0x2E
,
0x81
);
return
VIDEO_MODE_NTSC
;
}
/* 50Hz -> PAL/SECAM */
saa7110_write
(
decoder
,
0x0D
,
0x06
);
saa7110_write
(
decoder
,
0x11
,
0x59
);
saa7110_write
(
decoder
,
0x2E
,
0x9A
);
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x06
);
i2c_smbus_write_byte_data
(
client
,
0x11
,
0x59
);
i2c_smbus_write_byte_data
(
client
,
0x2E
,
0x9A
);
mdelay
(
150
);
/* pause 150 ms */
status
=
saa7110_read
(
decoder
);
status
=
i2c_smbus_read_byte
(
client
);
if
((
status
&
0x03
)
==
0x01
)
{
DEBUG
(
printk
(
KERN_INFO
"%s: norm=secam
\n
"
,
dev
->
name
));
saa7110_write
(
decoder
,
0x0D
,
0x07
);
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x07
);
return
VIDEO_MODE_SECAM
;
}
DEBUG
(
printk
(
KERN_INFO
"%s: norm=pal
\n
"
,
dev
->
name
));
...
...
@@ -188,7 +147,7 @@ int determine_norm(struct i2c_device* dev)
}
static
int
saa7110_attach
(
struct
i2c_
device
*
device
)
int
saa7110_attach
(
struct
i2c_
adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
{
static
const
unsigned
char
initseq
[]
=
{
0
,
0x4C
,
0x3C
,
0x0D
,
0xEF
,
0xBD
,
0xF0
,
0x00
,
0x00
,
...
...
@@ -198,20 +157,28 @@ static const unsigned char initseq[] = {
0xD9
,
0x17
,
0x40
,
0x41
,
0x80
,
0x41
,
0x80
,
0x4F
,
0xFE
,
0x01
,
0xCF
,
0x0F
,
0x03
,
0x01
,
0x81
,
0x03
,
0x40
,
0x75
,
0x01
,
0x8C
,
0x03
};
struct
saa7110
*
decoder
;
struct
saa7110
*
decoder
;
struct
i2c_client
*
client
;
int
rv
;
device
->
data
=
decoder
=
kmalloc
(
sizeof
(
struct
saa7110
),
GFP_KERNEL
);
if
(
device
->
data
==
0
)
client
=
kmalloc
(
sizeof
(
*
client
),
GFP_KERNEL
);
if
(
client
==
NULL
)
return
-
ENOMEM
;
client_template
.
adapter
=
adap
;
client_template
.
addr
=
addr
;
memcpy
(
client
,
&
client_template
,
sizeof
(
*
client
));
MOD_INC_USE_COUNT
;
decoder
=
kmalloc
(
sizeof
(
*
decoder
),
GFP_KERNEL
);
if
(
decoder
==
NULL
)
{
kfree
(
client
);
return
-
ENOMEM
;
}
/* clear our private data */
memset
(
decoder
,
0
,
sizeof
(
struct
saa7110
));
strcpy
(
device
->
name
,
"saa7110"
);
decoder
->
bus
=
device
->
bus
;
decoder
->
addr
=
device
->
addr
;
memset
(
decoder
,
0
,
sizeof
(
*
decoder
));
strcpy
(
client
->
name
,
IF_NAME
);
decoder
->
client
=
client
;
client
->
data
=
decoder
;
decoder
->
addr
=
addr
;
decoder
->
norm
=
VIDEO_MODE_PAL
;
decoder
->
input
=
0
;
decoder
->
enable
=
1
;
...
...
@@ -220,40 +187,52 @@ static const unsigned char initseq[] = {
decoder
->
hue
=
32768
;
decoder
->
sat
=
32768
;
rv
=
saa7110_write_block
(
decoder
,
initseq
,
sizeof
(
initseq
));
rv
=
i2c_master_send
(
client
,
initseq
,
sizeof
(
initseq
));
if
(
rv
<
0
)
printk
(
KERN_ERR
"%s_attach: init status %d
\n
"
,
device
->
name
,
rv
);
printk
(
KERN_ERR
"%s_attach: init status %d
\n
"
,
client
->
name
,
rv
);
else
{
saa7110_write
(
decoder
,
0x21
,
0x16
);
saa7110_write
(
decoder
,
0x0D
,
0x04
);
DEBUG
(
printk
(
KERN_INFO
"%s_attach: chip version %x
\n
"
,
device
->
name
,
saa7110_read
(
decoder
)));
saa7110_write
(
decoder
,
0x0D
,
0x06
);
i2c_smbus_write_byte_data
(
client
,
0x21
,
0x16
);
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x04
);
DEBUG
(
printk
(
KERN_INFO
"%s_attach: chip version %x
\n
"
,
client
->
name
,
i2c_smbus_read_byte
(
client
)));
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x06
);
}
init_MUTEX
(
&
decoder
->
lock
);
i2c_attach_client
(
client
);
MOD_INC_USE_COUNT
;
/* setup and implicit mode 0 select has been performed */
return
0
;
}
static
int
saa7110_probe
(
struct
i2c_adapter
*
adap
)
{
return
i2c_probe
(
adap
,
&
addr_data
,
saa7110_attach
);
}
static
int
saa7110_detach
(
struct
i2c_
device
*
device
)
int
saa7110_detach
(
struct
i2c_
client
*
client
)
{
struct
saa7110
*
decoder
=
device
->
data
;
struct
saa7110
*
decoder
=
client
->
data
;
DEBUG
(
printk
(
KERN_INFO
"%s_detach
\n
"
,
device
->
name
));
i2c_detach_client
(
client
);
DEBUG
(
printk
(
KERN_INFO
"%s_detach
\n
"
,
client
->
name
));
/* stop further output */
saa7110_write
(
decoder
,
0x0E
,
0x00
);
i2c_smbus_write_byte_data
(
client
,
0x0E
,
0x00
);
kfree
(
device
->
data
);
kfree
(
decoder
);
kfree
(
client
);
MOD_DEC_USE_COUNT
;
return
0
;
}
static
int
saa7110_command
(
struct
i2c_
device
*
device
,
unsigned
int
cmd
,
void
*
arg
)
int
saa7110_command
(
struct
i2c_
client
*
client
,
unsigned
int
cmd
,
void
*
arg
)
{
struct
saa7110
*
decoder
=
device
->
data
;
struct
saa7110
*
decoder
=
client
->
data
;
int
v
;
switch
(
cmd
)
{
...
...
@@ -272,11 +251,11 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
case
DECODER_GET_STATUS
:
{
struct
saa7110
*
decoder
=
device
->
data
;
struct
saa7110
*
decoder
=
client
->
data
;
int
status
;
int
res
=
0
;
status
=
i2c_
read
(
device
->
bus
,
device
->
addr
|
1
);
status
=
i2c_
smbus_read_byte
(
client
);
if
(
status
&
0x40
)
res
|=
DECODER_STATUS_GOOD
;
if
(
status
&
0x03
)
...
...
@@ -301,26 +280,26 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
v
=
*
(
int
*
)
arg
;
if
(
decoder
->
norm
!=
v
)
{
decoder
->
norm
=
v
;
saa7110_write
(
decoder
,
0x06
,
0x00
);
i2c_smbus_write_byte_data
(
client
,
0x06
,
0x00
);
switch
(
v
)
{
case
VIDEO_MODE_NTSC
:
saa7110_write
(
decoder
,
0x0D
,
0x06
);
saa7110_write
(
decoder
,
0x11
,
0x2C
);
saa7110_write
(
decoder
,
0x30
,
0x81
);
saa7110_write
(
decoder
,
0x2A
,
0xDF
);
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x06
);
i2c_smbus_write_byte_data
(
client
,
0x11
,
0x2C
);
i2c_smbus_write_byte_data
(
client
,
0x30
,
0x81
);
i2c_smbus_write_byte_data
(
client
,
0x2A
,
0xDF
);
break
;
case
VIDEO_MODE_PAL
:
saa7110_write
(
decoder
,
0x0D
,
0x06
);
saa7110_write
(
decoder
,
0x11
,
0x59
);
saa7110_write
(
decoder
,
0x2E
,
0x9A
);
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x06
);
i2c_smbus_write_byte_data
(
client
,
0x11
,
0x59
);
i2c_smbus_write_byte_data
(
client
,
0x2E
,
0x9A
);
break
;
case
VIDEO_MODE_SECAM
:
saa7110_write
(
decoder
,
0x0D
,
0x07
);
saa7110_write
(
decoder
,
0x11
,
0x59
);
saa7110_write
(
decoder
,
0x2E
,
0x9A
);
i2c_smbus_write_byte_data
(
client
,
0x0D
,
0x07
);
i2c_smbus_write_byte_data
(
client
,
0x11
,
0x59
);
i2c_smbus_write_byte_data
(
client
,
0x2E
,
0x9A
);
break
;
case
VIDEO_MODE_AUTO
:
*
(
int
*
)
arg
=
determine_norm
(
device
);
*
(
int
*
)
arg
=
determine_norm
(
client
);
break
;
default:
return
-
EPERM
;
...
...
@@ -334,7 +313,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
return
-
EINVAL
;
if
(
decoder
->
input
!=
v
)
{
decoder
->
input
=
v
;
saa7110_selmux
(
device
,
v
);
saa7110_selmux
(
client
,
v
);
}
break
;
...
...
@@ -349,7 +328,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
v
=
*
(
int
*
)
arg
;
if
(
decoder
->
enable
!=
v
)
{
decoder
->
enable
=
v
;
saa7110_write
(
decoder
,
0x0E
,
v
?
0x18
:
0x00
);
i2c_smbus_write_byte_data
(
client
,
0x0E
,
v
?
0x18
:
0x00
);
}
break
;
...
...
@@ -360,22 +339,22 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
if
(
decoder
->
bright
!=
pic
->
brightness
)
{
/* We want 0 to 255 we get 0-65535 */
decoder
->
bright
=
pic
->
brightness
;
saa7110_write
(
decoder
,
0x19
,
decoder
->
bright
>>
8
);
i2c_smbus_write_byte_data
(
client
,
0x19
,
decoder
->
bright
>>
8
);
}
if
(
decoder
->
contrast
!=
pic
->
contrast
)
{
/* We want 0 to 127 we get 0-65535 */
decoder
->
contrast
=
pic
->
contrast
;
saa7110_write
(
decoder
,
0x13
,
decoder
->
contrast
>>
9
);
i2c_smbus_write_byte_data
(
client
,
0x13
,
decoder
->
contrast
>>
9
);
}
if
(
decoder
->
sat
!=
pic
->
colour
)
{
/* We want 0 to 127 we get 0-65535 */
decoder
->
sat
=
pic
->
colour
;
saa7110_write
(
decoder
,
0x12
,
decoder
->
sat
>>
9
);
i2c_smbus_write_byte_data
(
client
,
0x12
,
decoder
->
sat
>>
9
);
}
if
(
decoder
->
hue
!=
pic
->
hue
)
{
/* We want -128 to 127 we get 0-65535 */
decoder
->
hue
=
pic
->
hue
;
saa7110_write
(
decoder
,
0x07
,
(
decoder
->
hue
>>
8
)
-
128
);
i2c_smbus_write_byte_data
(
client
,
0x07
,
(
decoder
->
hue
>>
8
)
-
128
);
}
}
break
;
...
...
@@ -383,7 +362,7 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
case
DECODER_DUMP
:
for
(
v
=
0
;
v
<
34
;
v
+=
16
)
{
int
j
;
DEBUG
(
printk
(
KERN_INFO
"%s: %03x
\n
"
,
device
->
name
,
v
));
DEBUG
(
printk
(
KERN_INFO
"%s: %03x
\n
"
,
client
->
name
,
v
));
for
(
j
=
0
;
j
<
16
;
j
++
)
{
DEBUG
(
printk
(
KERN_INFO
" %02x"
,
decoder
->
reg
[
v
+
j
]));
}
...
...
@@ -402,24 +381,30 @@ int saa7110_command(struct i2c_device *device, unsigned int cmd, void *arg)
static
struct
i2c_driver
i2c_driver_saa7110
=
{
"saa7110"
,
/* name */
I2C_DRIVERID_VIDEODECODER
,
/* in i2c.h */
I2C_SAA7110
,
I2C_SAA7110
+
1
,
/* Addr range */
saa7110_attach
,
IF_NAME
,
/* name */
I2C_DRIVERID_SAA7110
,
/* in i2c.h */
I2C_DF_NOTIFY
,
/* Addr range */
saa7110_probe
,
saa7110_detach
,
saa7110_command
};
static
struct
i2c_client
client_template
=
{
"saa7110_client"
,
-
1
,
0
,
0
,
NULL
,
&
i2c_driver_saa7110
};
static
int
saa7110_init
(
void
)
{
return
i2c_
register
_driver
(
&
i2c_driver_saa7110
);
return
i2c_
add
_driver
(
&
i2c_driver_saa7110
);
}
static
void
saa7110_exit
(
void
)
{
i2c_
unregister
_driver
(
&
i2c_driver_saa7110
);
i2c_
del
_driver
(
&
i2c_driver_saa7110
);
}
...
...
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