Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 77b2555b52a894a2e39a42e43d993df875c46a6a 102 lines 3.5 kB view raw
1#ifndef __SOUND_I2C_H 2#define __SOUND_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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 21 * 22 */ 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 */ 28 29struct _snd_i2c_device { 30 struct list_head list; 31 snd_i2c_bus_t *bus; /* I2C bus */ 32 char name[32]; /* some useful device name */ 33 unsigned short flags; /* device flags */ 34 unsigned short addr; /* device address (might be 10-bit) */ 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 42typedef struct _snd_i2c_bit_ops { 43 void (*start)(snd_i2c_bus_t *bus); /* transfer start */ 44 void (*stop)(snd_i2c_bus_t *bus); /* transfer stop */ 45 void (*direction)(snd_i2c_bus_t *bus, int clock, int data); /* set line direction (0 = write, 1 = read) */ 46 void (*setlines)(snd_i2c_bus_t *bus, int clock, int data); 47 int (*getclock)(snd_i2c_bus_t *bus); 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 */ 60 61 struct semaphore lock_mutex; 62 63 snd_i2c_bus_t *master; /* master bus when SCK/SCL is shared */ 64 struct list_head buses; /* master: slave buses sharing SCK/SCL, slave: link list */ 65 66 struct list_head devices; /* attached devices to this bus */ 67 68 union { 69 snd_i2c_bit_ops_t *bit; 70 void *ops; 71 } hw_ops; /* lowlevel operations */ 72 snd_i2c_ops_t *ops; /* midlevel operations */ 73 74 unsigned long private_value; 75 void *private_data; 76 void (*private_free)(snd_i2c_bus_t *bus); 77}; 78 79#define snd_i2c_slave_bus(n) list_entry(n, snd_i2c_bus_t, buses) 80 81int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master, snd_i2c_bus_t **ri2c); 82int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char addr, snd_i2c_device_t **rdevice); 83int snd_i2c_device_free(snd_i2c_device_t *device); 84 85static inline void snd_i2c_lock(snd_i2c_bus_t *bus) { 86 if (bus->master) 87 down(&bus->master->lock_mutex); 88 else 89 down(&bus->lock_mutex); 90} 91static inline void snd_i2c_unlock(snd_i2c_bus_t *bus) { 92 if (bus->master) 93 up(&bus->master->lock_mutex); 94 else 95 up(&bus->lock_mutex); 96} 97 98int snd_i2c_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); 99int snd_i2c_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); 100int snd_i2c_probeaddr(snd_i2c_bus_t *bus, unsigned short addr); 101 102#endif /* __SOUND_I2C_H */