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
a913beae
Commit
a913beae
authored
Nov 25, 2002
by
Alan Cox
Committed by
Linus Torvalds
Nov 25, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] update sa7111/7185 to new i2c
parent
72ad73df
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
159 additions
and
203 deletions
+159
-203
drivers/media/video/saa7111.c
drivers/media/video/saa7111.c
+84
-106
drivers/media/video/saa7185.c
drivers/media/video/saa7185.c
+75
-97
No files found.
drivers/media/video/saa7111.c
View file @
a913beae
This diff is collapsed.
Click to expand it.
drivers/media/video/saa7185.c
View file @
a913beae
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
#include <linux/version.h>
#include <linux/version.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <linux/i2c
-old
.h>
#include <linux/i2c.h>
#include <linux/video_encoder.h>
#include <linux/video_encoder.h>
...
@@ -52,9 +52,10 @@
...
@@ -52,9 +52,10 @@
/* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */
struct
saa7185
{
struct
saa7185
{
struct
i2c_
bus
*
bus
;
struct
i2c_
client
*
client
;
int
addr
;
int
addr
;
unsigned
char
reg
[
128
];
unsigned
char
reg
[
128
];
struct
semaphore
lock
;
int
norm
;
int
norm
;
int
enable
;
int
enable
;
...
@@ -69,66 +70,25 @@ struct saa7185 {
...
@@ -69,66 +70,25 @@ struct saa7185 {
#define I2C_DELAY 10
#define I2C_DELAY 10
/* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */
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
,
.
normal_i2c_range
=
normal_i2c_range
,
.
probe
=
probe
,
.
probe_range
=
probe_range
,
.
ignore
=
ignore
,
.
ignore_range
=
ignore_range
,
.
force
=
force
};
static
int
saa7185_read
(
struct
saa7185
*
dev
)
static
struct
i2c_client
client_template
;
{
int
ack
;
LOCK_I2C_BUS
(
dev
->
bus
);
i2c_start
(
dev
->
bus
);
i2c_sendbyte
(
dev
->
bus
,
dev
->
addr
|
1
,
I2C_DELAY
);
ack
=
i2c_readbyte
(
dev
->
bus
,
1
);
i2c_stop
(
dev
->
bus
);
UNLOCK_I2C_BUS
(
dev
->
bus
);
return
ack
;
}
static
int
saa7185_write
(
struct
saa7185
*
dev
,
unsigned
char
subaddr
,
unsigned
char
data
)
{
int
ack
;
DEBUG
(
printk
(
KERN_DEBUG
"SAA7185: %02x set to %02x
\n
"
,
subaddr
,
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
);
ack
=
i2c_sendbyte
(
dev
->
bus
,
data
,
I2C_DELAY
);
dev
->
reg
[
subaddr
]
=
data
;
i2c_stop
(
dev
->
bus
);
UNLOCK_I2C_BUS
(
dev
->
bus
);
return
ack
;
}
static
int
saa7185_write_block
(
struct
saa7185
*
dev
,
unsigned
const
char
*
data
,
unsigned
int
len
)
{
int
ack
=
-
1
;
unsigned
subaddr
;
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
;
}
/* ----------------------------------------------------------------------- */
static
const
unsigned
char
init_common
[]
=
{
static
const
unsigned
char
init_common
[]
=
{
0x3a
,
0x0f
,
/* CBENB=0, V656=0, VY2C=1, YUV2C=1, MY2C=1, MUV2C=1 */
0x3a
,
0x0f
,
/* CBENB=0, V656=0, VY2C=1, YUV2C=1, MY2C=1, MUV2C=1 */
...
@@ -222,58 +182,71 @@ static const unsigned char init_ntsc[] = {
...
@@ -222,58 +182,71 @@ static const unsigned char init_ntsc[] = {
0x66
,
0x21
,
/* FSC3 */
0x66
,
0x21
,
/* FSC3 */
};
};
static
int
saa7185_attach
(
struct
i2c_
device
*
device
)
static
int
saa7185_attach
(
struct
i2c_
adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
{
{
int
i
;
int
i
;
struct
saa7185
*
encoder
;
struct
saa7185
*
encoder
;
struct
i2c_client
client
;
MOD_INC_USE_COUNT
;
client
=
kmalloc
(
sizeof
(
*
client
),
GFP_KERNEL
);
if
(
client
==
NULL
)
device
->
data
=
encoder
=
kmalloc
(
sizeof
(
struct
saa7185
),
GFP_KERNEL
);
return
-
ENOMEM
;
client_template
.
adapter
=
adap
;
client_template
.
addr
=
addr
;
memcpy
(
client
,
&
client_template
,
sizeof
(
*
client
));
encoder
=
kmalloc
(
sizeof
(
*
decoder
),
GFP_KERNEL
);
if
(
encoder
==
NULL
)
{
if
(
encoder
==
NULL
)
{
MOD_DEC_USE_COUNT
;
kfree
(
client
)
;
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
memset
(
encoder
,
0
,
sizeof
(
struct
saa7185
));
memset
(
encoder
,
0
,
sizeof
(
*
decoder
));
strcpy
(
device
->
name
,
"saa7185"
);
strcpy
(
client
->
name
,
"saa7185"
);
encoder
->
bus
=
device
->
bus
;
encoder
->
client
=
client
;
encoder
->
addr
=
device
->
addr
;
client
->
data
=
encoder
;
encoder
->
addr
=
addr
;
encoder
->
norm
=
VIDEO_MODE_NTSC
;
encoder
->
norm
=
VIDEO_MODE_NTSC
;
encoder
->
enable
=
1
;
encoder
->
enable
=
1
;
i
=
saa7185_write_block
(
encoder
,
init_common
,
sizeof
(
init_common
));
i
=
i2c_master_send
(
client
,
init_common
,
sizeof
(
init_common
));
if
(
i
>=
0
)
{
if
(
i
>=
0
)
{
i
=
saa7185_write_block
(
encoder
,
init_ntsc
,
i
=
i2c_master_send
(
client
,
init_ntsc
,
sizeof
(
init_ntsc
));
sizeof
(
init_ntsc
));
}
}
if
(
i
<
0
)
{
if
(
i
<
0
)
{
printk
(
KERN_ERR
"%s_attach: init error %d
\n
"
,
device
->
name
,
printk
(
KERN_ERR
"%s_attach: init error %d
\n
"
,
client
->
name
,
i
);
i
);
}
else
{
}
else
{
printk
(
KERN_INFO
"%s_attach: chip version %d
\n
"
,
printk
(
KERN_INFO
"%s_attach: chip version %d
\n
"
,
device
->
name
,
saa7185_read
(
encoder
)
>>
5
);
client
->
name
,
i2c_smbus_read_byte
(
client
)
>>
5
);
}
}
init_MUTEX
(
&
decoder
->
lock
);
i2c_attach_client
(
client
);
MOD_INC_USE_COUNT
;
return
0
;
return
0
;
}
}
static
int
saa7185_probe
(
struct
i2c_adapter
*
adap
)
{
return
i2c_probe
(
adap
,
&
addr_data
,
saa7185_attach
);
}
static
int
saa7185_detach
(
struct
i2c_client
*
client
)
static
int
saa7185_detach
(
struct
i2c_device
*
device
)
{
{
struct
saa7185
*
encoder
=
device
->
data
;
struct
saa7185
*
encoder
=
client
->
data
;
saa7185_write
(
encoder
,
0x61
,
(
encoder
->
reg
[
0x61
])
|
0x40
);
/* SW: output off is active */
i2c_detach_client
(
client
);
//saa7185_write(encoder, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */
i2c_smbus_write_byte_data
(
client
,
0x61
,
(
encoder
->
reg
[
0x61
])
|
0x40
);
/* SW: output off is active */
//i2c_smbus_write_byte_data(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */
kfree
(
encoder
);
kfree
(
encoder
);
kfree
(
client
);
MOD_DEC_USE_COUNT
;
MOD_DEC_USE_COUNT
;
return
0
;
return
0
;
}
}
static
int
saa7185_command
(
struct
i2c_
device
*
device
,
unsigned
int
cmd
,
static
int
saa7185_command
(
struct
i2c_
client
*
client
,
unsigned
int
cmd
,
void
*
arg
)
void
*
arg
)
{
{
struct
saa7185
*
encoder
=
device
->
data
;
struct
saa7185
*
encoder
=
client
->
data
;
switch
(
cmd
)
{
switch
(
cmd
)
{
...
@@ -297,12 +270,12 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
...
@@ -297,12 +270,12 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
switch
(
*
iarg
)
{
switch
(
*
iarg
)
{
case
VIDEO_MODE_NTSC
:
case
VIDEO_MODE_NTSC
:
saa7185_write_block
(
encoder
,
init_ntsc
,
i2c_master_send
(
client
,
init_ntsc
,
sizeof
(
init_ntsc
));
sizeof
(
init_ntsc
));
break
;
break
;
case
VIDEO_MODE_PAL
:
case
VIDEO_MODE_PAL
:
saa7185_write_block
(
encoder
,
init_pal
,
i2c_master_send
(
client
,
init_pal
,
sizeof
(
init_pal
));
sizeof
(
init_pal
));
break
;
break
;
...
@@ -326,19 +299,19 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
...
@@ -326,19 +299,19 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
case
0
:
case
0
:
/* Switch RTCE to 1 */
/* Switch RTCE to 1 */
saa7185_write
(
encoder
,
0x61
,
i2c_smbus_write_byte_data
(
client
,
0x61
,
(
encoder
->
(
encoder
->
reg
[
0x61
]
&
0xf7
)
|
0x08
);
reg
[
0x61
]
&
0xf7
)
|
0x08
);
saa7185_write
(
encoder
,
0x6e
,
0x01
);
i2c_smbus_write_byte_data
(
client
,
0x6e
,
0x01
);
break
;
break
;
case
1
:
case
1
:
/* Switch RTCE to 0 */
/* Switch RTCE to 0 */
saa7185_write
(
encoder
,
0x61
,
i2c_smbus_write_byte_data
(
client
,
0x61
,
(
encoder
->
(
encoder
->
reg
[
0x61
]
&
0xf7
)
|
0x00
);
reg
[
0x61
]
&
0xf7
)
|
0x00
);
/* SW: a slight sync problem... */
/* SW: a slight sync problem... */
saa7185_write
(
encoder
,
0x6e
,
0x00
);
i2c_smbus_write_byte_data
(
client
,
0x6e
,
0x00
);
break
;
break
;
default:
default:
...
@@ -364,7 +337,7 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
...
@@ -364,7 +337,7 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
int
*
iarg
=
arg
;
int
*
iarg
=
arg
;
encoder
->
enable
=
!!*
iarg
;
encoder
->
enable
=
!!*
iarg
;
saa7185_write
(
encoder
,
0x61
,
i2c_smbus_write_byte_data
(
client
,
0x61
,
(
encoder
->
(
encoder
->
reg
[
0x61
]
&
0xbf
)
|
(
encoder
->
reg
[
0x61
]
&
0xbf
)
|
(
encoder
->
enable
?
0x00
:
enable
?
0x00
:
...
@@ -382,23 +355,28 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
...
@@ -382,23 +355,28 @@ static int saa7185_command(struct i2c_device *device, unsigned int cmd,
/* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */
static
struct
i2c_driver
i2c_driver_saa7185
=
{
static
struct
i2c_driver
i2c_driver_saa7185
=
{
"saa7185"
,
/* name */
.
name
=
"saa7185"
,
/* name */
I2C_DRIVERID_VIDEOENCODER
,
/* ID */
.
id
=
I2C_DRIVERID_SAA7185B
,
/* ID */
I2C_SAA7185
,
I2C_SAA7185
+
1
,
.
flags
=
I2C_DF_NOTIFY
,
.
attach_adapter
=
saa7185_probe
,
.
detach_client
=
saa7185_detach
,
.
command
=
saa7185_command
};
saa7185_attach
,
static
struct
i2c_client
client_template
=
{
saa7185_detach
,
.
name
=
"saa7185_client"
,
saa7185_command
.
id
=
-
1
,
.
driver
=
&
i2c_driver_saa7185
};
};
static
int
saa7185_init
(
void
)
static
int
saa7185_init
(
void
)
{
{
return
i2c_
register
_driver
(
&
i2c_driver_saa7185
);
return
i2c_
add
_driver
(
&
i2c_driver_saa7185
);
}
}
static
void
saa7185_exit
(
void
)
static
void
saa7185_exit
(
void
)
{
{
i2c_
unregister
_driver
(
&
i2c_driver_saa7185
);
i2c_
del
_driver
(
&
i2c_driver_saa7185
);
}
}
module_init
(
saa7185_init
);
module_init
(
saa7185_init
);
...
...
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