HW consumer¶
IIO 设备可以直接连接到硬件中的另一个设备。在这种情况下,IIO 提供者和 IIO 消费者之间的缓冲区由硬件处理。 Industrial I/O HW consumer 提供了一种绑定这些 IIO 设备的方法,而无需用于数据的软件缓冲区。 该实现可以在 drivers/iio/buffer/hw-consumer.c
下找到
struct iio_hw_consumer — 硬件消费者结构
iio_hw_consumer_alloc()
— 分配 IIO 硬件消费者iio_hw_consumer_free()
— 释放 IIO 硬件消费者iio_hw_consumer_enable()
— 启用 IIO 硬件消费者iio_hw_consumer_disable()
— 禁用 IIO 硬件消费者
HW consumer 设置¶
作为标准 IIO 设备,该实现基于 IIO 提供者/消费者。 典型的 IIO HW consumer 设置如下所示
static struct iio_hw_consumer *hwc;
static const struct iio_info adc_info = {
.read_raw = adc_read_raw,
};
static int adc_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
{
ret = iio_hw_consumer_enable(hwc);
/* Acquire data */
ret = iio_hw_consumer_disable(hwc);
}
static int adc_probe(struct platform_device *pdev)
{
hwc = devm_iio_hw_consumer_alloc(&iio->dev);
}
更多详细信息¶
-
void iio_hw_consumer_free(struct iio_hw_consumer *hwc)¶
释放 IIO 硬件消费者
参数
struct iio_hw_consumer *hwc
要释放的 hw consumer。
-
struct iio_hw_consumer *devm_iio_hw_consumer_alloc(struct device *dev)¶
资源管理的
iio_hw_consumer_alloc()
参数
struct device *dev
指向消费者设备的指针。
描述
Managed iio_hw_consumer_alloc。 使用此函数分配的 iio_hw_consumer 在驱动程序分离时自动释放。
成功时返回指向已分配的 iio_hw_consumer 的指针,失败时返回 NULL。
-
int iio_hw_consumer_enable(struct iio_hw_consumer *hwc)¶
启用 IIO 硬件消费者
参数
struct iio_hw_consumer *hwc
要启用的 iio_hw_consumer。
描述
成功时返回 0。
-
void iio_hw_consumer_disable(struct iio_hw_consumer *hwc)¶
禁用 IIO 硬件消费者
参数
struct iio_hw_consumer *hwc
要禁用的 iio_hw_consumer。