aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/i2c.h
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2006-01-07 09:40:05 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-01-07 09:40:05 -0500
commit123656d4cc8c946f578ebd18c2050f5251720428 (patch)
tree3d5432eff034a3b9cfdc98b37e245abe5695342d /include/sound/i2c.h
parenta62c80e559809e6c7851ec04d30575e85ad6f6ed (diff)
parent0aec63e67c69545ca757a73a66f5dcf05fa484bf (diff)
Merge with Linus' kernel.
Diffstat (limited to 'include/sound/i2c.h')
-rw-r--r--include/sound/i2c.h78
1 files changed, 40 insertions, 38 deletions
diff --git a/include/sound/i2c.h b/include/sound/i2c.h
index a665ddf9c146..81eb23ed761f 100644
--- a/include/sound/i2c.h
+++ b/include/sound/i2c.h
@@ -21,82 +21,84 @@
21 * 21 *
22 */ 22 */
23 23
24typedef struct _snd_i2c_device snd_i2c_device_t;
25typedef struct _snd_i2c_bus snd_i2c_bus_t;
26
27#define SND_I2C_DEVICE_ADDRTEN (1<<0) /* 10-bit I2C address */ 24#define SND_I2C_DEVICE_ADDRTEN (1<<0) /* 10-bit I2C address */
28 25
29struct _snd_i2c_device { 26struct snd_i2c_device {
30 struct list_head list; 27 struct list_head list;
31 snd_i2c_bus_t *bus; /* I2C bus */ 28 struct snd_i2c_bus *bus; /* I2C bus */
32 char name[32]; /* some useful device name */ 29 char name[32]; /* some useful device name */
33 unsigned short flags; /* device flags */ 30 unsigned short flags; /* device flags */
34 unsigned short addr; /* device address (might be 10-bit) */ 31 unsigned short addr; /* device address (might be 10-bit) */
35 unsigned long private_value; 32 unsigned long private_value;
36 void *private_data; 33 void *private_data;
37 void (*private_free)(snd_i2c_device_t *device); 34 void (*private_free)(struct snd_i2c_device *device);
35};
36
37#define snd_i2c_device(n) list_entry(n, struct snd_i2c_device, list)
38
39struct snd_i2c_bit_ops {
40 void (*start)(struct snd_i2c_bus *bus); /* transfer start */
41 void (*stop)(struct snd_i2c_bus *bus); /* transfer stop */
42 void (*direction)(struct snd_i2c_bus *bus, int clock, int data); /* set line direction (0 = write, 1 = read) */
43 void (*setlines)(struct snd_i2c_bus *bus, int clock, int data);
44 int (*getclock)(struct snd_i2c_bus *bus);
45 int (*getdata)(struct snd_i2c_bus *bus, int ack);
38}; 46};
39 47
40#define snd_i2c_device(n) list_entry(n, snd_i2c_device_t, list) 48struct snd_i2c_ops {
41 49 int (*sendbytes)(struct snd_i2c_device *device, unsigned char *bytes, int count);
42typedef struct _snd_i2c_bit_ops { 50 int (*readbytes)(struct snd_i2c_device *device, unsigned char *bytes, int count);
43 void (*start)(snd_i2c_bus_t *bus); /* transfer start */ 51 int (*probeaddr)(struct snd_i2c_bus *bus, unsigned short addr);
44 void (*stop)(snd_i2c_bus_t *bus); /* transfer stop */ 52};
45 void (*direction)(snd_i2c_bus_t *bus, int clock, int data); /* set line direction (0 = write, 1 = read) */ 53
46 void (*setlines)(snd_i2c_bus_t *bus, int clock, int data); 54struct snd_i2c_bus {
47 int (*getclock)(snd_i2c_bus_t *bus); 55 struct snd_card *card; /* card which I2C belongs to */
48 int (*getdata)(snd_i2c_bus_t *bus, int ack);
49} snd_i2c_bit_ops_t;
50
51typedef struct _snd_i2c_ops {
52 int (*sendbytes)(snd_i2c_device_t *device, unsigned char *bytes, int count);
53 int (*readbytes)(snd_i2c_device_t *device, unsigned char *bytes, int count);
54 int (*probeaddr)(snd_i2c_bus_t *bus, unsigned short addr);
55} snd_i2c_ops_t;
56
57struct _snd_i2c_bus {
58 snd_card_t *card; /* card which I2C belongs to */
59 char name[32]; /* some useful label */ 56 char name[32]; /* some useful label */
60 57
61 struct semaphore lock_mutex; 58 struct semaphore lock_mutex;
62 59
63 snd_i2c_bus_t *master; /* master bus when SCK/SCL is shared */ 60 struct snd_i2c_bus *master; /* master bus when SCK/SCL is shared */
64 struct list_head buses; /* master: slave buses sharing SCK/SCL, slave: link list */ 61 struct list_head buses; /* master: slave buses sharing SCK/SCL, slave: link list */
65 62
66 struct list_head devices; /* attached devices to this bus */ 63 struct list_head devices; /* attached devices to this bus */
67 64
68 union { 65 union {
69 snd_i2c_bit_ops_t *bit; 66 struct snd_i2c_bit_ops *bit;
70 void *ops; 67 void *ops;
71 } hw_ops; /* lowlevel operations */ 68 } hw_ops; /* lowlevel operations */
72 snd_i2c_ops_t *ops; /* midlevel operations */ 69 struct snd_i2c_ops *ops; /* midlevel operations */
73 70
74 unsigned long private_value; 71 unsigned long private_value;
75 void *private_data; 72 void *private_data;
76 void (*private_free)(snd_i2c_bus_t *bus); 73 void (*private_free)(struct snd_i2c_bus *bus);
77}; 74};
78 75
79#define snd_i2c_slave_bus(n) list_entry(n, snd_i2c_bus_t, buses) 76#define snd_i2c_slave_bus(n) list_entry(n, struct snd_i2c_bus, buses)
80 77
81int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master, snd_i2c_bus_t **ri2c); 78int snd_i2c_bus_create(struct snd_card *card, const char *name,
82int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char addr, snd_i2c_device_t **rdevice); 79 struct snd_i2c_bus *master, struct snd_i2c_bus **ri2c);
83int snd_i2c_device_free(snd_i2c_device_t *device); 80int snd_i2c_device_create(struct snd_i2c_bus *bus, const char *name,
81 unsigned char addr, struct snd_i2c_device **rdevice);
82int snd_i2c_device_free(struct snd_i2c_device *device);
84 83
85static inline void snd_i2c_lock(snd_i2c_bus_t *bus) { 84static inline void snd_i2c_lock(struct snd_i2c_bus *bus)
85{
86 if (bus->master) 86 if (bus->master)
87 down(&bus->master->lock_mutex); 87 down(&bus->master->lock_mutex);
88 else 88 else
89 down(&bus->lock_mutex); 89 down(&bus->lock_mutex);
90} 90}
91static inline void snd_i2c_unlock(snd_i2c_bus_t *bus) { 91
92static inline void snd_i2c_unlock(struct snd_i2c_bus *bus)
93{
92 if (bus->master) 94 if (bus->master)
93 up(&bus->master->lock_mutex); 95 up(&bus->master->lock_mutex);
94 else 96 else
95 up(&bus->lock_mutex); 97 up(&bus->lock_mutex);
96} 98}
97 99
98int snd_i2c_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); 100int snd_i2c_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count);
99int snd_i2c_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); 101int snd_i2c_readbytes(struct snd_i2c_device *device, unsigned char *bytes, int count);
100int snd_i2c_probeaddr(snd_i2c_bus_t *bus, unsigned short addr); 102int snd_i2c_probeaddr(struct snd_i2c_bus *bus, unsigned short addr);
101 103
102#endif /* __SOUND_I2C_H */ 104#endif /* __SOUND_I2C_H */