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。