source: GPL/alsa-kernel/include/sound/i2c.h@ 18

Last change on this file since 18 was 18, checked in by vladest, 20 years ago

initial import

File size: 3.0 KB
Line 
1#ifndef __SND_I2C_H
2#define __SND_I2C_H
3
4/*
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 *
22 */
23
24#define SNDRV_LOCK_I2C_BUS(bus) spin_lock_irqsave(&bus->lock, flags)
25#define SNDRV_UNLOCK_I2C_BUS(bus) spin_unlock_irqrestore(&bus->lock, flags)
26
27typedef struct _snd_i2c_device snd_i2c_device_t;
28typedef struct _snd_i2c_bus snd_i2c_bus_t;
29
30struct _snd_i2c_device {
31 struct list_head list;
32 snd_i2c_bus_t *bus; /* I2C bus */
33 char name[32]; /* some useful device name */
34 unsigned char addr; /* device address */
35 unsigned long private_value;
36 void *private_data;
37 void (*private_free)(snd_i2c_device_t *device);
38};
39
40#define snd_i2c_device(n) list_entry(n, snd_i2c_device_t, list)
41
42struct _snd_i2c_bus {
43 snd_card_t *card; /* card which I2C belongs to */
44 char name[32]; /* some useful label */
45
46 spinlock_t lock;
47
48 struct list_head devices; /* attached devices */
49
50 /* Software I2C */
51 void (*i2c_setlines) (snd_i2c_bus_t * bus, int ctrl, int data);
52 int (*i2c_getdataline) (snd_i2c_bus_t * bus);
53
54 /* Hardware I2C */
55 int (*i2c_read) (snd_i2c_bus_t * bus, unsigned char addr);
56 int (*i2c_write) (snd_i2c_bus_t * bus, unsigned char addr, unsigned char b1, unsigned char b2, int both);
57
58 unsigned long private_value;
59 void *private_data;
60 void (*private_free)(snd_i2c_bus_t *bus);
61};
62
63
64int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t **ri2c);
65int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char addr, snd_i2c_device_t **rdevice);
66int snd_i2c_device_free(snd_i2c_device_t *device);
67
68/* i2c bus access functions */
69void snd_i2c_reset(snd_i2c_bus_t *bus);
70void snd_i2c_start(snd_i2c_bus_t *bus);
71void snd_i2c_stop(snd_i2c_bus_t *bus);
72void snd_i2c_one(snd_i2c_bus_t *bus);
73void snd_i2c_zero(snd_i2c_bus_t *bus);
74int snd_i2c_ack(snd_i2c_bus_t *bus);
75
76int snd_i2c_sendbyte(snd_i2c_bus_t *bus, unsigned char data, int wait_for_ack);
77unsigned char snd_i2c_readbyte(snd_i2c_bus_t *bus, int last);
78
79/* i2c (maybe) hardware functions */
80int snd_i2c_read(snd_i2c_bus_t *bus, unsigned char addr);
81int snd_i2c_write(snd_i2c_bus_t *bus, unsigned char addr, unsigned char b1, unsigned char b2, int both);
82int snd_i2c_dev_read(snd_i2c_device_t *device);
83int snd_i2c_dev_write(snd_i2c_device_t *device, unsigned char b1, unsigned char b2, int both);
84
85#endif /* __SND_I2C_H */
Note: See TracBrowser for help on using the repository browser.