clear-pkgs-linux-iot-lts2018/0283-ASoC-rt700-codec-chang...

113 lines
3.2 KiB
Diff

From 6496d2dc1cc0de18c38448a7796baa692eedcc02 Mon Sep 17 00:00:00 2001
From: Sanyog Kale <sanyog.r.kale@intel.com>
Date: Thu, 27 Oct 2016 12:04:26 +0530
Subject: [PATCH 283/743] ASoC: rt700: codec changes for BRA feature
This patch create sysfs entry to test BRA feature.
sysfs entry created: /sys/bus/soundwire/devices/<slave>/bra_trigger
On reading this sysfs entry, codec driver will initiate
BRA read request of 36 bytes to bus driver. On successful
packet transfer, bus driver will return SUCCESS with 36
bytes copied in buffer provided by codec driver.
Signed-off-by: Sanyog Kale <sanyog.r.kale@intel.com>
---
sound/soc/codecs/rt700.c | 73 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c
index 8cb67827a8db..773e77bc7ed6 100644
--- a/sound/soc/codecs/rt700.c
+++ b/sound/soc/codecs/rt700.c
@@ -1432,6 +1432,70 @@ static int rt700_clock_config(struct device *dev, struct alc700 *alc700)
return 0;
}
+static int rt700_create_bra_block(struct sdw_slv *slave)
+{
+ struct sdw_bra_block bra_block;
+ u8 *value;
+ int ret = 0;
+
+ /* Fill bra data structure */
+ bra_block.slave_addr = slave->slv_addr->slv_number;
+ bra_block.cmd = 0; /* Read command */
+ bra_block.num_bytes = 36; /* 36 bytes */
+ bra_block.reg_offset = 0x0000;
+
+ value = kzalloc(bra_block.num_bytes, GFP_KERNEL);
+ if (!value)
+ return -ENOMEM;
+
+ /* Memset with some fixed pattern */
+ memset(value, 0xAB, bra_block.num_bytes);
+ bra_block.values = value;
+
+ pr_info("SDW: BRA: slv_addr:%d, cmd:%d, num_bytes:%d, reg_offset:0x%x\n",
+ bra_block.slave_addr,
+ bra_block.cmd,
+ bra_block.num_bytes,
+ bra_block.reg_offset);
+
+ print_hex_dump(KERN_DEBUG, "SDW: BRA: CODEC BUFFER:", DUMP_PREFIX_OFFSET, 8, 4,
+ bra_block.values, bra_block.num_bytes, false);
+
+
+ ret = sdw_slave_xfer_bra_block(slave->mstr, &bra_block);
+ if (ret) {
+ dev_err(&slave->dev, "SDW: BRA transfer failed\n");
+ kfree(bra_block.values);
+ return ret;
+ }
+
+ print_hex_dump(KERN_DEBUG, "SDW: BRA: CODEC BUFFER RCVD:", DUMP_PREFIX_OFFSET, 8, 4,
+ bra_block.values, bra_block.num_bytes, false);
+
+ pr_info("SDW: BRA: Transfer successful\n");
+
+ /* Free up memory */
+ kfree(bra_block.values);
+
+ return ret;
+}
+
+static ssize_t rt700_bra_trigger(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+
+ struct rt700_priv *rt700 = dev_get_drvdata(dev);
+
+ pm_runtime_get_sync(dev);
+
+ rt700_create_bra_block(rt700->sdw);
+
+ pm_runtime_put_sync(dev);
+
+ return 0;
+}
+static DEVICE_ATTR(bra_trigger, 0444, rt700_bra_trigger, NULL);
+
int rt700_probe(struct device *dev, struct regmap *regmap,
struct sdw_slave *slave)
{
@@ -1548,6 +1612,15 @@ int rt700_probe(struct device *dev, struct regmap *regmap,
return ret;
}
+ /* create sysfs entry */
+ ret = device_create_file(dev, &dev_attr_bra_trigger);
+ if (ret < 0)
+ return ret;
+
+ pm_runtime_get_sync(&rt700->sdw->mstr->dev);
+ pm_runtime_mark_last_busy(&rt700->sdw->mstr->dev);
+ pm_runtime_put_sync_autosuspend(&rt700->sdw->mstr->dev);
+
pm_runtime_set_autosuspend_delay(&slave->dev, 3000);
pm_runtime_use_autosuspend(&slave->dev);
pm_runtime_enable(&slave->dev);
--
2.19.2