commit_title
stringlengths
13
124
commit_body
stringlengths
0
1.9k
release_summary
stringclasses
52 values
changes_summary
stringlengths
1
758
release_affected_domains
stringclasses
33 values
release_affected_drivers
stringclasses
51 values
domain_of_changes
stringlengths
2
571
language_set
stringclasses
983 values
diffstat_files
int64
1
300
diffstat_insertions
int64
0
309k
diffstat_deletions
int64
0
168k
commit_diff
stringlengths
92
23.4M
category
stringclasses
108 values
commit_hash
stringlengths
34
40
related_people
stringlengths
0
370
domain
stringclasses
21 values
subdomain
stringclasses
241 values
leaf_module
stringlengths
0
912
wil6210: support set_multicast_to_unicast cfg80211 operation
wil6210 ap has a separate ring for transmitting multicast packets, multicast packets are transmitted without an ack from the receiver side. therefore, 802.11 spec defines some low mcs rates for multicat packets. however, there is no guarantee that these packets were really received and handled on the client side.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
support set_multicast_to_unicast cfg80211 operation
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['wil6210 ']
['c', 'h']
3
48
1
--- diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c +static int wil_cfg80211_set_multicast_to_unicast(struct wiphy *wiphy, + struct net_device *dev, + const bool enabled) +{ + struct wil6210_priv *wil = wiphy_to_wil(wiphy); + + if (wil->multicast_to_unicast == enabled) + return 0; + + wil_info(wil, "set multicast to unicast, enabled=%d ", enabled); + wil->multicast_to_unicast = enabled; + + return 0; +} + + .set_multicast_to_unicast = wil_cfg80211_set_multicast_to_unicast, diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c --- a/drivers/net/wireless/ath/wil6210/txrx.c +++ b/drivers/net/wireless/ath/wil6210/txrx.c +#include <linux/if_vlan.h> +/* apply multicast to unicast only for arp and ip packets + * (see nl80211_cmd_set_multicast_to_unicast for more info) + */ +static bool wil_check_multicast_to_unicast(struct wil6210_priv *wil, + struct sk_buff *skb) +{ + const struct ethhdr *eth = (void *)skb->data; + const struct vlan_ethhdr *ethvlan = (void *)skb->data; + __be16 ethertype; + + if (!wil->multicast_to_unicast) + return false; + + /* multicast to unicast conversion only for some payload */ + ethertype = eth->h_proto; + if (ethertype == htons(eth_p_8021q) && skb->len >= vlan_eth_hlen) + ethertype = ethvlan->h_vlan_encapsulated_proto; + switch (ethertype) { + case htons(eth_p_arp): + case htons(eth_p_ip): + case htons(eth_p_ipv6): + break; + default: + return false; + } + + return true; +} + - if (vif->pbss) + if (vif->pbss || wil_check_multicast_to_unicast(wil, skb)) diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h --- a/drivers/net/wireless/ath/wil6210/wil6210.h +++ b/drivers/net/wireless/ath/wil6210/wil6210.h + u8 multicast_to_unicast;
Networking
5e5f069c30ccdbc09bd548858ee75d0487e74490
ahmad masri
drivers
net
ath, wil6210, wireless
wlcore: mesh: add support for rx broadcast key
in order to support authentication of equals peers, need to save rx broadcast key per peer (on top of 1 tx broadcast key and unicast key per peer).
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for rx broadcast key
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['wlcore', 'mesh']
['c', 'h']
4
21
11
--- diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c --- a/drivers/net/wireless/ti/wlcore/cmd.c +++ b/drivers/net/wireless/ti/wlcore/cmd.c - u16 tx_seq_16) + u16 tx_seq_16, bool is_pairwise) - } else { + } else if (is_pairwise) { + } else { + lid_type = broadcast_lid_type; diff --git a/drivers/net/wireless/ti/wlcore/cmd.h b/drivers/net/wireless/ti/wlcore/cmd.h --- a/drivers/net/wireless/ti/wlcore/cmd.h +++ b/drivers/net/wireless/ti/wlcore/cmd.h - u16 tx_seq_16); + u16 tx_seq_16, bool is_pairwise); diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c - u16 tx_seq_16) + u16 tx_seq_16, bool is_pairwise) + ap_key->is_pairwise = is_pairwise; - key->tx_seq_16); + key->tx_seq_16, key->is_pairwise); - u16 tx_seq_16, struct ieee80211_sta *sta) + u16 tx_seq_16, struct ieee80211_sta *sta, + bool is_pairwise) - tx_seq_16); + tx_seq_16, is_pairwise); - tx_seq_16); + tx_seq_16, is_pairwise); + bool is_pairwise; + is_pairwise = key_conf->flags & ieee80211_key_flag_pairwise; + - tx_seq_32, tx_seq_16, sta); + tx_seq_32, tx_seq_16, sta, is_pairwise); - 0, 0, sta); + 0, 0, sta, is_pairwise); + ieee80211_hw_set(wl->hw, supports_per_sta_gtk); - wiphy_flag_has_channel_switch; + wiphy_flag_has_channel_switch | ++ wiphy_flag_ibss_rsn; diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h --- a/drivers/net/wireless/ti/wlcore/wlcore_i.h +++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h + bool is_pairwise;
Networking
cf33a7728bf27e6f8c5e9190410db85c11103699
maital hahn guy mishol guym ti com
drivers
net
ti, wireless, wlcore
soundwire: qcom: add support for soundwire controller
qualcomm soundwire master controller is present in most qualcomm socs either integrated as part of wcd audio codecs via slimbus or as part of soc i/o.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for soundwire controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['soundwire', 'qcom']
['c', 'kconfig', 'makefile']
3
874
0
--- diff --git a/drivers/soundwire/kconfig b/drivers/soundwire/kconfig --- a/drivers/soundwire/kconfig +++ b/drivers/soundwire/kconfig +config soundwire_qcom + tristate "qualcomm soundwire master driver" + depends on slimbus + depends on snd_soc + help + soundwire qualcomm master driver. + if you have an qualcomm platform which has a soundwire master then + enable this config option to get the soundwire support for that + device diff --git a/drivers/soundwire/makefile b/drivers/soundwire/makefile --- a/drivers/soundwire/makefile +++ b/drivers/soundwire/makefile + +#qualcomm driver +soundwire-qcom-objs := qcom.o +obj-$(config_soundwire_qcom) += soundwire-qcom.o diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- /dev/null +++ b/drivers/soundwire/qcom.c +// spdx-license-identifier: gpl-2.0 +// copyright (c) 2019, linaro limited + +#include <linux/clk.h> +#include <linux/completion.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/of_device.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/slimbus.h> +#include <linux/soundwire/sdw.h> +#include <linux/soundwire/sdw_registers.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include "bus.h" + +#define swrm_comp_hw_version 0x00 +#define swrm_comp_cfg_addr 0x04 +#define swrm_comp_cfg_irq_level_or_pulse_msk bit(1) +#define swrm_comp_cfg_enable_msk bit(0) +#define swrm_comp_params 0x100 +#define swrm_comp_params_dout_ports_mask genmask(4, 0) +#define swrm_comp_params_din_ports_mask genmask(9, 5) +#define swrm_interrupt_status 0x200 +#define swrm_interrupt_status_rmsk genmask(16, 0) +#define swrm_interrupt_status_new_slave_attached bit(1) +#define swrm_interrupt_status_change_enum_slave_status bit(2) +#define swrm_interrupt_status_cmd_error bit(7) +#define swrm_interrupt_status_special_cmd_id_finished bit(10) +#define swrm_interrupt_mask_addr 0x204 +#define swrm_interrupt_clear 0x208 +#define swrm_cmd_fifo_wr_cmd 0x300 +#define swrm_cmd_fifo_rd_cmd 0x304 +#define swrm_cmd_fifo_cmd 0x308 +#define swrm_cmd_fifo_status 0x30c +#define swrm_cmd_fifo_cfg_addr 0x314 +#define swrm_rd_wr_cmd_retries 0x7 +#define swrm_cmd_fifo_rd_fifo_addr 0x318 +#define swrm_enumerator_cfg_addr 0x500 +#define swrm_mcp_frame_ctrl_bank_addr(m) (0x101c + 0x40 * (m)) +#define swrm_mcp_frame_ctrl_bank_row_ctrl_shft 3 +#define swrm_mcp_frame_ctrl_bank_col_ctrl_bmsk genmask(2, 0) +#define swrm_mcp_frame_ctrl_bank_row_ctrl_bmsk genmask(7, 3) +#define swrm_mcp_frame_ctrl_bank_col_ctrl_shft 0 +#define swrm_mcp_cfg_addr 0x1048 +#define swrm_mcp_cfg_max_num_of_cmd_no_pings_bmsk genmask(21, 17) +#define swrm_mcp_cfg_max_num_of_cmd_no_pings_shft 0x11 +#define swrm_def_cmd_no_pings 0x1f +#define swrm_mcp_status 0x104c +#define swrm_mcp_status_bank_num_mask bit(0) +#define swrm_mcp_slv_status 0x1090 +#define swrm_mcp_slv_status_mask genmask(1, 0) +#define swrm_dp_port_ctrl_bank(n, m) (0x1124 + 0x100 * (n - 1) + 0x40 * m) +#define swrm_dp_port_ctrl_en_chan_shft 0x18 +#define swrm_dp_port_ctrl_offset2_shft 0x10 +#define swrm_dp_port_ctrl_offset1_shft 0x08 +#define swrm_ahb_bridge_wr_data_0 0xc85 +#define swrm_ahb_bridge_wr_addr_0 0xc89 +#define swrm_ahb_bridge_rd_addr_0 0xc8d +#define swrm_ahb_bridge_rd_data_0 0xc91 + +#define swrm_reg_val_pack(data, dev, id, reg) \ + ((reg) | ((id) << 16) | ((dev) << 20) | ((data) << 24)) + +#define swrm_max_row_val 0 /* rows = 48 */ +#define swrm_default_rows 48 +#define swrm_min_col_val 0 /* cols = 2 */ +#define swrm_default_col 16 +#define swrm_max_col_val 7 +#define swrm_special_cmd_id 0xf +#define max_freq_num 1 +#define timeout_ms (2 * hz) +#define qcom_swrm_max_rd_len 0xf +#define qcom_sdw_max_ports 14 +#define default_clk_freq 9600000 +#define swrm_max_dais 0xf + +struct qcom_swrm_port_config { + u8 si; + u8 off1; + u8 off2; +}; + +struct qcom_swrm_ctrl { + struct sdw_bus bus; + struct device *dev; + struct regmap *regmap; + struct completion *comp; + struct work_struct slave_work; + /* read/write lock */ + spinlock_t comp_lock; + /* port alloc/free lock */ + struct mutex port_lock; + struct clk *hclk; + u8 wr_cmd_id; + u8 rd_cmd_id; + int irq; + unsigned int version; + int num_din_ports; + int num_dout_ports; + unsigned long dout_port_mask; + unsigned long din_port_mask; + struct qcom_swrm_port_config pconfig[qcom_sdw_max_ports]; + struct sdw_stream_runtime *sruntime[swrm_max_dais]; + enum sdw_slave_status status[sdw_max_devices]; + int (*reg_read)(struct qcom_swrm_ctrl *ctrl, int reg, u32 *val); + int (*reg_write)(struct qcom_swrm_ctrl *ctrl, int reg, int val); +}; + +#define to_qcom_sdw(b) container_of(b, struct qcom_swrm_ctrl, bus) + +static int qcom_swrm_abh_reg_read(struct qcom_swrm_ctrl *ctrl, int reg, + u32 *val) +{ + struct regmap *wcd_regmap = ctrl->regmap; + int ret; + + /* pg register + offset */ + ret = regmap_bulk_write(wcd_regmap, swrm_ahb_bridge_rd_addr_0, + (u8 *)&reg, 4); + if (ret < 0) + return sdw_cmd_fail; + + ret = regmap_bulk_read(wcd_regmap, swrm_ahb_bridge_rd_data_0, + val, 4); + if (ret < 0) + return sdw_cmd_fail; + + return sdw_cmd_ok; +} + +static int qcom_swrm_ahb_reg_write(struct qcom_swrm_ctrl *ctrl, + int reg, int val) +{ + struct regmap *wcd_regmap = ctrl->regmap; + int ret; + /* pg register + offset */ + ret = regmap_bulk_write(wcd_regmap, swrm_ahb_bridge_wr_data_0, + (u8 *)&val, 4); + if (ret) + return sdw_cmd_fail; + + /* write address register */ + ret = regmap_bulk_write(wcd_regmap, swrm_ahb_bridge_wr_addr_0, + (u8 *)&reg, 4); + if (ret) + return sdw_cmd_fail; + + return sdw_cmd_ok; +} + +static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *ctrl, u8 cmd_data, + u8 dev_addr, u16 reg_addr) +{ + declare_completion_onstack(comp); + unsigned long flags; + u32 val; + int ret; + + spin_lock_irqsave(&ctrl->comp_lock, flags); + ctrl->comp = &comp; + spin_unlock_irqrestore(&ctrl->comp_lock, flags); + val = swrm_reg_val_pack(cmd_data, dev_addr, + swrm_special_cmd_id, reg_addr); + ret = ctrl->reg_write(ctrl, swrm_cmd_fifo_wr_cmd, val); + if (ret) + goto err; + + ret = wait_for_completion_timeout(ctrl->comp, + msecs_to_jiffies(timeout_ms)); + + if (!ret) + ret = sdw_cmd_ignored; + else + ret = sdw_cmd_ok; +err: + spin_lock_irqsave(&ctrl->comp_lock, flags); + ctrl->comp = null; + spin_unlock_irqrestore(&ctrl->comp_lock, flags); + + return ret; +} + +static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *ctrl, + u8 dev_addr, u16 reg_addr, + u32 len, u8 *rval) +{ + int i, ret; + u32 val; + declare_completion_onstack(comp); + unsigned long flags; + + spin_lock_irqsave(&ctrl->comp_lock, flags); + ctrl->comp = &comp; + spin_unlock_irqrestore(&ctrl->comp_lock, flags); + + val = swrm_reg_val_pack(len, dev_addr, swrm_special_cmd_id, reg_addr); + ret = ctrl->reg_write(ctrl, swrm_cmd_fifo_rd_cmd, val); + if (ret) + goto err; + + ret = wait_for_completion_timeout(ctrl->comp, + msecs_to_jiffies(timeout_ms)); + + if (!ret) { + ret = sdw_cmd_ignored; + goto err; + } else { + ret = sdw_cmd_ok; + } + + for (i = 0; i < len; i++) { + ctrl->reg_read(ctrl, swrm_cmd_fifo_rd_fifo_addr, &val); + rval[i] = val & 0xff; + } + +err: + spin_lock_irqsave(&ctrl->comp_lock, flags); + ctrl->comp = null; + spin_unlock_irqrestore(&ctrl->comp_lock, flags); + + return ret; +} + +static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl) +{ + u32 val; + int i; + + ctrl->reg_read(ctrl, swrm_mcp_slv_status, &val); + + for (i = 0; i < sdw_max_devices; i++) { + u32 s; + + s = (val >> (i * 2)); + s &= swrm_mcp_slv_status_mask; + ctrl->status[i] = s; + } +} + +static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id) +{ + struct qcom_swrm_ctrl *ctrl = dev_id; + u32 sts, value; + unsigned long flags; + + ctrl->reg_read(ctrl, swrm_interrupt_status, &sts); + + if (sts & swrm_interrupt_status_cmd_error) { + ctrl->reg_read(ctrl, swrm_cmd_fifo_status, &value); + dev_err_ratelimited(ctrl->dev, + "cmd error, fifo status 0x%x ", + value); + ctrl->reg_write(ctrl, swrm_cmd_fifo_cmd, 0x1); + } + + if ((sts & swrm_interrupt_status_new_slave_attached) || + sts & swrm_interrupt_status_change_enum_slave_status) + schedule_work(&ctrl->slave_work); + + /** + * clear the interrupt before complete() is called, as complete can + * schedule new read/writes which require interrupts, clearing the + * interrupt would avoid missing interrupts in such cases. + */ + ctrl->reg_write(ctrl, swrm_interrupt_clear, sts); + + if (sts & swrm_interrupt_status_special_cmd_id_finished) { + spin_lock_irqsave(&ctrl->comp_lock, flags); + if (ctrl->comp) + complete(ctrl->comp); + spin_unlock_irqrestore(&ctrl->comp_lock, flags); + } + + return irq_handled; +} +static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl) +{ + u32 val; + + /* clear rows and cols */ + val = (swrm_max_row_val << swrm_mcp_frame_ctrl_bank_row_ctrl_shft | + swrm_min_col_val << swrm_mcp_frame_ctrl_bank_col_ctrl_shft); + + ctrl->reg_write(ctrl, swrm_mcp_frame_ctrl_bank_addr(0), val); + + /* disable auto enumeration */ + ctrl->reg_write(ctrl, swrm_enumerator_cfg_addr, 0); + + /* mask soundwire interrupts */ + ctrl->reg_write(ctrl, swrm_interrupt_mask_addr, + swrm_interrupt_status_rmsk); + + /* configure no pings */ + ctrl->reg_read(ctrl, swrm_mcp_cfg_addr, &val); + val &= ~swrm_mcp_cfg_max_num_of_cmd_no_pings_bmsk; + val |= (swrm_def_cmd_no_pings << + swrm_mcp_cfg_max_num_of_cmd_no_pings_shft); + ctrl->reg_write(ctrl, swrm_mcp_cfg_addr, val); + + /* configure number of retries of a read/write cmd */ + ctrl->reg_write(ctrl, swrm_cmd_fifo_cfg_addr, swrm_rd_wr_cmd_retries); + + /* set irq to pulse */ + ctrl->reg_write(ctrl, swrm_comp_cfg_addr, + swrm_comp_cfg_irq_level_or_pulse_msk | + swrm_comp_cfg_enable_msk); + return 0; +} + +static enum sdw_command_response qcom_swrm_xfer_msg(struct sdw_bus *bus, + struct sdw_msg *msg) +{ + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + int ret, i, len; + + if (msg->flags == sdw_msg_flag_read) { + for (i = 0; i < msg->len;) { + if ((msg->len - i) < qcom_swrm_max_rd_len) + len = msg->len - i; + else + len = qcom_swrm_max_rd_len; + + ret = qcom_swrm_cmd_fifo_rd_cmd(ctrl, msg->dev_num, + msg->addr + i, len, + &msg->buf[i]); + if (ret) + return ret; + + i = i + len; + } + } else if (msg->flags == sdw_msg_flag_write) { + for (i = 0; i < msg->len; i++) { + ret = qcom_swrm_cmd_fifo_wr_cmd(ctrl, msg->buf[i], + msg->dev_num, + msg->addr + i); + if (ret) + return sdw_cmd_ignored; + } + } + + return sdw_cmd_ok; +} + +static int qcom_swrm_pre_bank_switch(struct sdw_bus *bus) +{ + u32 reg = swrm_mcp_frame_ctrl_bank_addr(bus->params.next_bank); + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + u32 val; + + ctrl->reg_read(ctrl, reg, &val); + + val &= ~swrm_mcp_frame_ctrl_bank_col_ctrl_bmsk; + val &= ~swrm_mcp_frame_ctrl_bank_row_ctrl_bmsk; + + val |= (swrm_max_row_val << swrm_mcp_frame_ctrl_bank_row_ctrl_shft | + swrm_max_col_val << swrm_mcp_frame_ctrl_bank_col_ctrl_shft); + + return ctrl->reg_write(ctrl, reg, val); +} + +static int qcom_swrm_port_params(struct sdw_bus *bus, + struct sdw_port_params *p_params, + unsigned int bank) +{ + /* tbd */ + return 0; +} + +static int qcom_swrm_transport_params(struct sdw_bus *bus, + struct sdw_transport_params *params, + enum sdw_reg_bank bank) +{ + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + u32 value; + + value = params->offset1 << swrm_dp_port_ctrl_offset1_shft; + value |= params->offset2 << swrm_dp_port_ctrl_offset2_shft; + value |= params->sample_interval - 1; + + return ctrl->reg_write(ctrl, + swrm_dp_port_ctrl_bank((params->port_num), bank), + value); +} + +static int qcom_swrm_port_enable(struct sdw_bus *bus, + struct sdw_enable_ch *enable_ch, + unsigned int bank) +{ + u32 reg = swrm_dp_port_ctrl_bank(enable_ch->port_num, bank); + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + u32 val; + + ctrl->reg_read(ctrl, reg, &val); + + if (enable_ch->enable) + val |= (enable_ch->ch_mask << swrm_dp_port_ctrl_en_chan_shft); + else + val &= ~(0xff << swrm_dp_port_ctrl_en_chan_shft); + + return ctrl->reg_write(ctrl, reg, val); +} + +static struct sdw_master_port_ops qcom_swrm_port_ops = { + .dpn_set_port_params = qcom_swrm_port_params, + .dpn_set_port_transport_params = qcom_swrm_transport_params, + .dpn_port_enable_ch = qcom_swrm_port_enable, +}; + +static struct sdw_master_ops qcom_swrm_ops = { + .xfer_msg = qcom_swrm_xfer_msg, + .pre_bank_switch = qcom_swrm_pre_bank_switch, +}; + +static int qcom_swrm_compute_params(struct sdw_bus *bus) +{ + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + struct sdw_master_runtime *m_rt; + struct sdw_slave_runtime *s_rt; + struct sdw_port_runtime *p_rt; + struct qcom_swrm_port_config *pcfg; + int i = 0; + + list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { + list_for_each_entry(p_rt, &m_rt->port_list, port_node) { + pcfg = &ctrl->pconfig[p_rt->num - 1]; + p_rt->transport_params.port_num = p_rt->num; + p_rt->transport_params.sample_interval = pcfg->si + 1; + p_rt->transport_params.offset1 = pcfg->off1; + p_rt->transport_params.offset2 = pcfg->off2; + } + + list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { + list_for_each_entry(p_rt, &s_rt->port_list, port_node) { + pcfg = &ctrl->pconfig[i]; + p_rt->transport_params.port_num = p_rt->num; + p_rt->transport_params.sample_interval = + pcfg->si + 1; + p_rt->transport_params.offset1 = pcfg->off1; + p_rt->transport_params.offset2 = pcfg->off2; + i++; + } + } + } + + return 0; +} + +static u32 qcom_swrm_freq_tbl[max_freq_num] = { + default_clk_freq, +}; + +static void qcom_swrm_slave_wq(struct work_struct *work) +{ + struct qcom_swrm_ctrl *ctrl = + container_of(work, struct qcom_swrm_ctrl, slave_work); + + qcom_swrm_get_device_status(ctrl); + sdw_handle_slave_status(&ctrl->bus, ctrl->status); +} + + +static void qcom_swrm_stream_free_ports(struct qcom_swrm_ctrl *ctrl, + struct sdw_stream_runtime *stream) +{ + struct sdw_master_runtime *m_rt; + struct sdw_port_runtime *p_rt; + unsigned long *port_mask; + + mutex_lock(&ctrl->port_lock); + + list_for_each_entry(m_rt, &stream->master_list, stream_node) { + if (m_rt->direction == sdw_data_dir_rx) + port_mask = &ctrl->dout_port_mask; + else + port_mask = &ctrl->din_port_mask; + + list_for_each_entry(p_rt, &m_rt->port_list, port_node) + clear_bit(p_rt->num - 1, port_mask); + } + + mutex_unlock(&ctrl->port_lock); +} + +static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, + struct sdw_stream_runtime *stream, + struct snd_pcm_hw_params *params, + int direction) +{ + struct sdw_port_config pconfig[qcom_sdw_max_ports]; + struct sdw_stream_config sconfig; + struct sdw_master_runtime *m_rt; + struct sdw_slave_runtime *s_rt; + struct sdw_port_runtime *p_rt; + unsigned long *port_mask; + int i, maxport, pn, nports = 0, ret = 0; + + mutex_lock(&ctrl->port_lock); + list_for_each_entry(m_rt, &stream->master_list, stream_node) { + if (m_rt->direction == sdw_data_dir_rx) { + maxport = ctrl->num_dout_ports; + port_mask = &ctrl->dout_port_mask; + } else { + maxport = ctrl->num_din_ports; + port_mask = &ctrl->din_port_mask; + } + + list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { + list_for_each_entry(p_rt, &s_rt->port_list, port_node) { + /* port numbers start from 1 - 14*/ + pn = find_first_zero_bit(port_mask, maxport); + if (pn > (maxport - 1)) { + dev_err(ctrl->dev, "all ports busy "); + ret = -ebusy; + goto err; + } + set_bit(pn, port_mask); + pconfig[nports].num = pn + 1; + pconfig[nports].ch_mask = p_rt->ch_mask; + nports++; + } + } + } + + if (direction == sndrv_pcm_stream_capture) + sconfig.direction = sdw_data_dir_tx; + else + sconfig.direction = sdw_data_dir_rx; + + /* hw parameters wil be ignored as we only support pdm */ + sconfig.ch_count = 1; + sconfig.frame_rate = params_rate(params); + sconfig.type = stream->type; + sconfig.bps = 1; + sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig, + nports, stream); +err: + if (ret) { + for (i = 0; i < nports; i++) + clear_bit(pconfig[i].num - 1, port_mask); + } + + mutex_unlock(&ctrl->port_lock); + + return ret; +} + +static int qcom_swrm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev); + struct sdw_stream_runtime *sruntime = ctrl->sruntime[dai->id]; + int ret; + + ret = qcom_swrm_stream_alloc_ports(ctrl, sruntime, params, + substream->stream); + if (ret) + qcom_swrm_stream_free_ports(ctrl, sruntime); + + return ret; +} + +static int qcom_swrm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev); + struct sdw_stream_runtime *sruntime = ctrl->sruntime[dai->id]; + + qcom_swrm_stream_free_ports(ctrl, sruntime); + sdw_stream_remove_master(&ctrl->bus, sruntime); + + return 0; +} + +static int qcom_swrm_set_sdw_stream(struct snd_soc_dai *dai, + void *stream, int direction) +{ + struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev); + + ctrl->sruntime[dai->id] = stream; + + return 0; +} + +static int qcom_swrm_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev); + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct sdw_stream_runtime *sruntime; + int ret, i; + + sruntime = sdw_alloc_stream(dai->name); + if (!sruntime) + return -enomem; + + ctrl->sruntime[dai->id] = sruntime; + + for (i = 0; i < rtd->num_codecs; i++) { + ret = snd_soc_dai_set_sdw_stream(rtd->codec_dais[i], sruntime, + substream->stream); + if (ret < 0 && ret != -enotsupp) { + dev_err(dai->dev, "failed to set sdw stream on %s", + rtd->codec_dais[i]->name); + sdw_release_stream(sruntime); + return ret; + } + } + + return 0; +} + +static void qcom_swrm_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev); + + sdw_release_stream(ctrl->sruntime[dai->id]); + ctrl->sruntime[dai->id] = null; +} + +static const struct snd_soc_dai_ops qcom_swrm_pdm_dai_ops = { + .hw_params = qcom_swrm_hw_params, + .hw_free = qcom_swrm_hw_free, + .startup = qcom_swrm_startup, + .shutdown = qcom_swrm_shutdown, + .set_sdw_stream = qcom_swrm_set_sdw_stream, +}; + +static const struct snd_soc_component_driver qcom_swrm_dai_component = { + .name = "soundwire", +}; + +static int qcom_swrm_register_dais(struct qcom_swrm_ctrl *ctrl) +{ + int num_dais = ctrl->num_dout_ports + ctrl->num_din_ports; + struct snd_soc_dai_driver *dais; + struct snd_soc_pcm_stream *stream; + struct device *dev = ctrl->dev; + int i; + + /* pdm dais are only tested for now */ + dais = devm_kcalloc(dev, num_dais, sizeof(*dais), gfp_kernel); + if (!dais) + return -enomem; + + for (i = 0; i < num_dais; i++) { + dais[i].name = devm_kasprintf(dev, gfp_kernel, "sdw pin%d", i); + if (!dais[i].name) + return -enomem; + + if (i < ctrl->num_dout_ports) + stream = &dais[i].playback; + else + stream = &dais[i].capture; + + stream->channels_min = 1; + stream->channels_max = 1; + stream->rates = sndrv_pcm_rate_48000; + stream->formats = sndrv_pcm_fmtbit_s16_le; + + dais[i].ops = &qcom_swrm_pdm_dai_ops; + dais[i].id = i; + } + + return devm_snd_soc_register_component(ctrl->dev, + &qcom_swrm_dai_component, + dais, num_dais); +} + +static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) +{ + struct device_node *np = ctrl->dev->of_node; + u8 off1[qcom_sdw_max_ports]; + u8 off2[qcom_sdw_max_ports]; + u8 si[qcom_sdw_max_ports]; + int i, ret, nports, val; + + ctrl->reg_read(ctrl, swrm_comp_params, &val); + + ctrl->num_dout_ports = val & swrm_comp_params_dout_ports_mask; + ctrl->num_din_ports = (val & swrm_comp_params_din_ports_mask) >> 5; + + ret = of_property_read_u32(np, "qcom,din-ports", &val); + if (ret) + return ret; + + if (val > ctrl->num_din_ports) + return -einval; + + ctrl->num_din_ports = val; + + ret = of_property_read_u32(np, "qcom,dout-ports", &val); + if (ret) + return ret; + + if (val > ctrl->num_dout_ports) + return -einval; + + ctrl->num_dout_ports = val; + + nports = ctrl->num_dout_ports + ctrl->num_din_ports; + + ret = of_property_read_u8_array(np, "qcom,ports-offset1", + off1, nports); + if (ret) + return ret; + + ret = of_property_read_u8_array(np, "qcom,ports-offset2", + off2, nports); + if (ret) + return ret; + + ret = of_property_read_u8_array(np, "qcom,ports-sinterval-low", + si, nports); + if (ret) + return ret; + + for (i = 0; i < nports; i++) { + ctrl->pconfig[i].si = si[i]; + ctrl->pconfig[i].off1 = off1[i]; + ctrl->pconfig[i].off2 = off2[i]; + } + + return 0; +} + +static int qcom_swrm_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct sdw_master_prop *prop; + struct sdw_bus_params *params; + struct qcom_swrm_ctrl *ctrl; + int ret; + u32 val; + + ctrl = devm_kzalloc(dev, sizeof(*ctrl), gfp_kernel); + if (!ctrl) + return -enomem; + + if (dev->parent->bus == &slimbus_bus) { + ctrl->reg_read = qcom_swrm_abh_reg_read; + ctrl->reg_write = qcom_swrm_ahb_reg_write; + ctrl->regmap = dev_get_regmap(dev->parent, null); + if (!ctrl->regmap) + return -einval; + } else { + /* only wcd based soundwire controller is supported */ + return -enotsupp; + } + + ctrl->irq = of_irq_get(dev->of_node, 0); + if (ctrl->irq < 0) + return ctrl->irq; + + ctrl->hclk = devm_clk_get(dev, "iface"); + if (is_err(ctrl->hclk)) + return ptr_err(ctrl->hclk); + + clk_prepare_enable(ctrl->hclk); + + ctrl->dev = dev; + dev_set_drvdata(&pdev->dev, ctrl); + spin_lock_init(&ctrl->comp_lock); + mutex_init(&ctrl->port_lock); + init_work(&ctrl->slave_work, qcom_swrm_slave_wq); + + ctrl->bus.dev = dev; + ctrl->bus.ops = &qcom_swrm_ops; + ctrl->bus.port_ops = &qcom_swrm_port_ops; + ctrl->bus.compute_params = &qcom_swrm_compute_params; + + ret = qcom_swrm_get_port_config(ctrl); + if (ret) + return ret; + + params = &ctrl->bus.params; + params->max_dr_freq = default_clk_freq; + params->curr_dr_freq = default_clk_freq; + params->col = swrm_default_col; + params->row = swrm_default_rows; + ctrl->reg_read(ctrl, swrm_mcp_status, &val); + params->curr_bank = val & swrm_mcp_status_bank_num_mask; + params->next_bank = !params->curr_bank; + + prop = &ctrl->bus.prop; + prop->max_clk_freq = default_clk_freq; + prop->num_clk_gears = 0; + prop->num_clk_freq = max_freq_num; + prop->clk_freq = &qcom_swrm_freq_tbl[0]; + prop->default_col = swrm_default_col; + prop->default_row = swrm_default_rows; + + ctrl->reg_read(ctrl, swrm_comp_hw_version, &ctrl->version); + + ret = devm_request_threaded_irq(dev, ctrl->irq, null, + qcom_swrm_irq_handler, + irqf_trigger_rising, + "soundwire", ctrl); + if (ret) { + dev_err(dev, "failed to request soundwire irq "); + goto err; + } + + ret = sdw_add_bus_master(&ctrl->bus); + if (ret) { + dev_err(dev, "failed to register soundwire controller (%d) ", + ret); + goto err; + } + + qcom_swrm_init(ctrl); + ret = qcom_swrm_register_dais(ctrl); + if (ret) + goto err; + + dev_info(dev, "qualcomm soundwire controller v%x.%x.%x registered ", + (ctrl->version >> 24) & 0xff, (ctrl->version >> 16) & 0xff, + ctrl->version & 0xffff); + + return 0; +err: + clk_disable_unprepare(ctrl->hclk); + return ret; +} + +static int qcom_swrm_remove(struct platform_device *pdev) +{ + struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev); + + sdw_delete_bus_master(&ctrl->bus); + clk_disable_unprepare(ctrl->hclk); + + return 0; +} + +static const struct of_device_id qcom_swrm_of_match[] = { + { .compatible = "qcom,soundwire-v1.3.0", }, + {/* sentinel */}, +}; + +module_device_table(of, qcom_swrm_of_match); + +static struct platform_driver qcom_swrm_driver = { + .probe = &qcom_swrm_probe, + .remove = &qcom_swrm_remove, + .driver = { + .name = "qcom-soundwire", + .of_match_table = qcom_swrm_of_match, + } +}; +module_platform_driver(qcom_swrm_driver); + +module_description("qualcomm soundwire driver"); +module_license("gpl v2");
Audio
02efb49aa805cee643a643ab61a1118c2fd08b80
srinivas kandagatla
drivers
soundwire
alsa: replace timespec with timespec64
since timespec is not year 2038 safe on 32bit system, and we need to convert all timespec variables to timespec64 type for sound subsystem.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h', 'c']
9
65
53
--- diff --git a/include/sound/pcm.h b/include/sound/pcm.h --- a/include/sound/pcm.h +++ b/include/sound/pcm.h - struct timespec *system_ts, struct timespec *audio_ts, + struct timespec64 *system_ts, struct timespec64 *audio_ts, - struct timespec trigger_tstamp; /* trigger timestamp */ + struct timespec64 trigger_tstamp; /* trigger timestamp */ - struct timespec driver_tstamp; + struct timespec64 driver_tstamp; - * snd_pcm_gettime - fill the timespec depending on the timestamp mode + * snd_pcm_gettime - fill the timespec64 depending on the timestamp mode - * @tv: timespec to fill + * @tv: timespec64 to fill - struct timespec *tv) + struct timespec64 *tv) - ktime_get_ts(tv); + ktime_get_ts64(tv); - getrawmonotonic(tv); + ktime_get_raw_ts64(tv); - getnstimeofday(tv); + ktime_get_real_ts64(tv); diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h - struct snd_pcm_substream *substream, struct timespec *system_ts, - struct timespec *audio_ts, + struct snd_pcm_substream *substream, struct timespec64 *system_ts, + struct timespec64 *audio_ts, diff --git a/include/sound/timer.h b/include/sound/timer.h --- a/include/sound/timer.h +++ b/include/sound/timer.h - struct timespec * tstamp, + struct timespec64 * tstamp, -void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp); +void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp); diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c - if (runtime->tstamp_mode == sndrv_pcm_tstamp_enable) - snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); + if (runtime->tstamp_mode == sndrv_pcm_tstamp_enable) { + struct timespec64 tstamp; + + snd_pcm_gettime(runtime, &tstamp); + runtime->status->tstamp = timespec64_to_timespec(tstamp); + } - struct timespec *curr_tstamp, - struct timespec *audio_tstamp) + struct timespec64 *curr_tstamp, + struct timespec64 *audio_tstamp) - struct timespec driver_tstamp; + struct timespec64 driver_tstamp; - *audio_tstamp = ns_to_timespec(audio_nsecs); + *audio_tstamp = ns_to_timespec64(audio_nsecs); - if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) { - runtime->status->audio_tstamp = *audio_tstamp; - runtime->status->tstamp = *curr_tstamp; + + if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec || + runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) { + runtime->status->audio_tstamp = + timespec64_to_timespec(*audio_tstamp); + runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp); + - snd_pcm_gettime(substream->runtime, (struct timespec *)&driver_tstamp); + snd_pcm_gettime(substream->runtime, &driver_tstamp); - struct timespec curr_tstamp; - struct timespec audio_tstamp; + struct timespec64 curr_tstamp; + struct timespec64 audio_tstamp; - snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp); + snd_pcm_gettime(runtime, &curr_tstamp); - snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp); + snd_pcm_gettime(runtime, &curr_tstamp); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c - status->trigger_tstamp = runtime->trigger_tstamp; + status->trigger_tstamp = timespec64_to_timespec(runtime->trigger_tstamp); - status->driver_tstamp = runtime->driver_tstamp; + status->driver_tstamp = timespec64_to_timespec(runtime->driver_tstamp); - if (runtime->tstamp_mode == sndrv_pcm_tstamp_enable) - snd_pcm_gettime(runtime, &status->tstamp); + if (runtime->tstamp_mode == sndrv_pcm_tstamp_enable) { + struct timespec64 tstamp; + + snd_pcm_gettime(runtime, &tstamp); + status->tstamp = timespec64_to_timespec(tstamp); + } diff --git a/sound/core/timer.c b/sound/core/timer.c --- a/sound/core/timer.c +++ b/sound/core/timer.c - struct timespec tstamp; /* trigger tstamp */ + struct timespec64 tstamp; /* trigger tstamp */ - struct timespec tstamp; + struct timespec64 tstamp; - ktime_get_ts(&tstamp); + ktime_get_ts64(&tstamp); - getnstimeofday(&tstamp); + ktime_get_real_ts64(&tstamp); -void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp) +void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp) - struct timespec *tstamp, + struct timespec64 *tstamp, - r1.tstamp = *tstamp; + r1.tstamp = timespec64_to_timespec(*tstamp); - struct timespec tstamp; + struct timespec64 tstamp; - ktime_get_ts(&tstamp); + ktime_get_ts64(&tstamp); - getnstimeofday(&tstamp); + ktime_get_real_ts64(&tstamp); - r1.tstamp = tstamp; + r1.tstamp = timespec64_to_timespec(tstamp); - r->tstamp = tstamp; + r->tstamp = timespec64_to_timespec(tstamp); - r1.tstamp = tstamp; + r1.tstamp = timespec64_to_timespec(tstamp); - status.tstamp = tu->tstamp; + status.tstamp = timespec64_to_timespec(tu->tstamp); diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c - struct timespec *tstamp, + struct timespec64 *tstamp, diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c - struct timespec *system_ts, struct timespec *audio_ts, + struct timespec64 *system_ts, struct timespec64 *audio_ts, - *audio_ts = ns_to_timespec(nsec); + *audio_ts = ns_to_timespec64(nsec); - *system_ts = ktime_to_timespec(xtstamp.sys_monoraw); + *system_ts = ktime_to_timespec64(xtstamp.sys_monoraw); - *system_ts = ktime_to_timespec(xtstamp.sys_realtime); + *system_ts = ktime_to_timespec64(xtstamp.sys_realtime); - *audio_ts = ktime_to_timespec(xtstamp.device); + *audio_ts = ktime_to_timespec64(xtstamp.device); diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c - struct timespec *system_ts, struct timespec *audio_ts, + struct timespec64 *system_ts, struct timespec64 *audio_ts, - *audio_ts = ns_to_timespec(nsec); + *audio_ts = ns_to_timespec64(nsec);
Audio
fcae40c99fb3d09f4407f549a7f17761abe5e1bc
baolin wang
include
sound
hda, intel, skylake
alsa: avoid using timespec for struct snd_timer_status
struct snd_timer_status uses 'timespec' type variables to record timestamp, which will be changed to an incompatible layout with updated user space using 64-bit time_t.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h', 'c']
3
64
57
--- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h +#ifndef __kernel__ +#endif diff --git a/sound/core/timer.c b/sound/core/timer.c --- a/sound/core/timer.c +++ b/sound/core/timer.c +struct snd_timer_status32 { + s32 tstamp_sec; /* timestamp - last update */ + s32 tstamp_nsec; + unsigned int resolution; /* current period resolution in ns */ + unsigned int lost; /* counter of master tick lost */ + unsigned int overrun; /* count of read queue overruns */ + unsigned int queue; /* used queue size */ + unsigned char reserved[64]; /* reserved */ +}; + +#define sndrv_timer_ioctl_status32 _ior('t', 0x14, struct snd_timer_status32) + +struct snd_timer_status64 { + s64 tstamp_sec; /* timestamp - last update */ + s64 tstamp_nsec; + unsigned int resolution; /* current period resolution in ns */ + unsigned int lost; /* counter of master tick lost */ + unsigned int overrun; /* count of read queue overruns */ + unsigned int queue; /* used queue size */ + unsigned char reserved[64]; /* reserved */ +}; + +#define sndrv_timer_ioctl_status64 _ior('t', 0x14, struct snd_timer_status64) + -static int snd_timer_user_status(struct file *file, - struct snd_timer_status __user *_status) +static int snd_timer_user_status32(struct file *file, + struct snd_timer_status32 __user *_status) + { + struct snd_timer_user *tu; + struct snd_timer_status32 status; + + tu = file->private_data; + if (!tu->timeri) + return -ebadfd; + memset(&status, 0, sizeof(status)); + status.tstamp_sec = tu->tstamp.tv_sec; + status.tstamp_nsec = tu->tstamp.tv_nsec; + status.resolution = snd_timer_resolution(tu->timeri); + status.lost = tu->timeri->lost; + status.overrun = tu->overrun; + spin_lock_irq(&tu->qlock); + status.queue = tu->qused; + spin_unlock_irq(&tu->qlock); + if (copy_to_user(_status, &status, sizeof(status))) + return -efault; + return 0; +} + +static int snd_timer_user_status64(struct file *file, + struct snd_timer_status64 __user *_status) - struct snd_timer_status status; + struct snd_timer_status64 status; - status.tstamp = timespec64_to_timespec(tu->tstamp); + status.tstamp_sec = tu->tstamp.tv_sec; + status.tstamp_nsec = tu->tstamp.tv_nsec; - case sndrv_timer_ioctl_status: - return snd_timer_user_status(file, argp); + case sndrv_timer_ioctl_status32: + return snd_timer_user_status32(file, argp); + case sndrv_timer_ioctl_status64: + return snd_timer_user_status64(file, argp); diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c -struct snd_timer_status32 { - struct compat_timespec tstamp; - u32 resolution; - u32 lost; - u32 overrun; - u32 queue; - unsigned char reserved[64]; -}; - -static int snd_timer_user_status_compat(struct file *file, - struct snd_timer_status32 __user *_status) -{ - struct snd_timer_user *tu; - struct snd_timer_status32 status; - - tu = file->private_data; - if (!tu->timeri) - return -ebadfd; - memset(&status, 0, sizeof(status)); - status.tstamp.tv_sec = tu->tstamp.tv_sec; - status.tstamp.tv_nsec = tu->tstamp.tv_nsec; - status.resolution = snd_timer_resolution(tu->timeri); - status.lost = tu->timeri->lost; - status.overrun = tu->overrun; - spin_lock_irq(&tu->qlock); - status.queue = tu->qused; - spin_unlock_irq(&tu->qlock); - if (copy_to_user(_status, &status, sizeof(status))) - return -efault; - return 0; -} - -#ifdef config_x86_x32 -/* x32 abi has the same struct as x86-64 */ -#define snd_timer_user_status_x32(file, s) \ - snd_timer_user_status(file, s) -#endif /* config_x86_x32 */ - -/* - */ - - sndrv_timer_ioctl_status32 = _iow('t', 0x14, struct snd_timer_status32), -#ifdef config_x86_x32 - sndrv_timer_ioctl_status_x32 = _iow('t', 0x14, struct snd_timer_status), -#endif /* config_x86_x32 */ + sndrv_timer_ioctl_status_compat32 = _iow('t', 0x14, struct snd_timer_status32), + sndrv_timer_ioctl_status_compat64 = _iow('t', 0x14, struct snd_timer_status64), - case sndrv_timer_ioctl_status32: - return snd_timer_user_status_compat(file, argp); -#ifdef config_x86_x32 - case sndrv_timer_ioctl_status_x32: - return snd_timer_user_status_x32(file, argp); -#endif /* config_x86_x32 */ + case sndrv_timer_ioctl_status_compat32: + return snd_timer_user_status32(file, argp); + case sndrv_timer_ioctl_status_compat64: + return snd_timer_user_status64(file, argp);
Audio
a07804cc7472d8aa5db03ea5d75f3d8d80abb687
baolin wang
sound
core
sound
alsa: avoid using timespec for struct snd_ctl_elem_value
the struct snd_ctl_elem_value will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h']
1
1
2
--- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h - struct timespec tstamp; - unsigned char reserved[128-sizeof(struct timespec)]; + unsigned char reserved[128];
Audio
a4e7dd35b9dac21fa7b33e8788b51c7fbc7a49f1
baolin wang
include
uapi
sound
alsa: avoid using timespec for struct snd_pcm_status
the struct snd_pcm_status will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h', 'c']
5
198
126
--- diff --git a/include/sound/pcm.h b/include/sound/pcm.h --- a/include/sound/pcm.h +++ b/include/sound/pcm.h +struct snd_pcm_status64; -int snd_pcm_status(struct snd_pcm_substream *substream, - struct snd_pcm_status *status); +int snd_pcm_status64(struct snd_pcm_substream *substream, + struct snd_pcm_status64 *status); +struct snd_pcm_status64 { + snd_pcm_state_t state; /* stream state */ + u8 rsvd[4]; + s64 trigger_tstamp_sec; /* time when stream was started/stopped/paused */ + s64 trigger_tstamp_nsec; + s64 tstamp_sec; /* reference timestamp */ + s64 tstamp_nsec; + snd_pcm_uframes_t appl_ptr; /* appl ptr */ + snd_pcm_uframes_t hw_ptr; /* hw ptr */ + snd_pcm_sframes_t delay; /* current delay in frames */ + snd_pcm_uframes_t avail; /* number of frames available */ + snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */ + snd_pcm_uframes_t overrange; /* count of adc (capture) overrange detections from last status */ + snd_pcm_state_t suspended_state; /* suspended stream state */ + __u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */ + s64 audio_tstamp_sec; /* sample counter, wall clock, phc or on-demand sync'ed */ + s64 audio_tstamp_nsec; + s64 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */ + s64 driver_tstamp_nsec; + __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ + unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */ +}; + +#define sndrv_pcm_ioctl_status64 _ior('a', 0x20, struct snd_pcm_status64) +#define sndrv_pcm_ioctl_status_ext64 _iowr('a', 0x24, struct snd_pcm_status64) + +struct snd_pcm_status32 { + s32 state; /* stream state */ + s32 trigger_tstamp_sec; /* time when stream was started/stopped/paused */ + s32 trigger_tstamp_nsec; + s32 tstamp_sec; /* reference timestamp */ + s32 tstamp_nsec; + u32 appl_ptr; /* appl ptr */ + u32 hw_ptr; /* hw ptr */ + s32 delay; /* current delay in frames */ + u32 avail; /* number of frames available */ + u32 avail_max; /* max frames available on hw since last status */ + u32 overrange; /* count of adc (capture) overrange detections from last status */ + s32 suspended_state; /* suspended stream state */ + u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */ + s32 audio_tstamp_sec; /* sample counter, wall clock, phc or on-demand sync'ed */ + s32 audio_tstamp_nsec; + s32 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */ + s32 driver_tstamp_nsec; + u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ + unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */ +}; + +#define sndrv_pcm_ioctl_status32 _ior('a', 0x20, struct snd_pcm_status32) +#define sndrv_pcm_ioctl_status_ext32 _iowr('a', 0x24, struct snd_pcm_status32) + diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h +#ifndef __kernel__ +/* explicit padding avoids incompatibility between i386 and x86-64 */ +typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)] __time_pad; + + __time_pad pad1; /* align to timespec */ +#endif diff --git a/sound/core/pcm.c b/sound/core/pcm.c --- a/sound/core/pcm.c +++ b/sound/core/pcm.c - struct snd_pcm_status status; + struct snd_pcm_status64 status; - err = snd_pcm_status(substream, &status); + err = snd_pcm_status64(substream, &status); - snd_iprintf(buffer, "trigger_time: %ld.%09ld ", - status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec); - snd_iprintf(buffer, "tstamp : %ld.%09ld ", - status.tstamp.tv_sec, status.tstamp.tv_nsec); + snd_iprintf(buffer, "trigger_time: %lld.%09lld ", + status.trigger_tstamp_sec, status.trigger_tstamp_nsec); + snd_iprintf(buffer, "tstamp : %lld.%09lld ", + status.tstamp_sec, status.tstamp_nsec); diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c -struct snd_pcm_status32 { +struct compat_snd_pcm_status64 { - struct compat_timespec trigger_tstamp; - struct compat_timespec tstamp; - u32 appl_ptr; - u32 hw_ptr; - s32 delay; - u32 avail; - u32 avail_max; - u32 overrange; - s32 suspended_state; - u32 audio_tstamp_data; - struct compat_timespec audio_tstamp; - struct compat_timespec driver_tstamp; - u32 audio_tstamp_accuracy; - unsigned char reserved[52-2*sizeof(struct compat_timespec)]; -} __attribute__((packed)); - - -static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream, - struct snd_pcm_status32 __user *src, - bool ext) -{ - struct snd_pcm_status status; - int err; - - memset(&status, 0, sizeof(status)); - /* - * with extension, parameters are read/write, - * get audio_tstamp_data from user, - * ignore rest of status structure - */ - if (ext && get_user(status.audio_tstamp_data, - (u32 __user *)(&src->audio_tstamp_data))) - return -efault; - err = snd_pcm_status(substream, &status); - if (err < 0) - return err; - - if (clear_user(src, sizeof(*src))) - return -efault; - if (put_user(status.state, &src->state) || - compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || - compat_put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.appl_ptr, &src->appl_ptr) || - put_user(status.hw_ptr, &src->hw_ptr) || - put_user(status.delay, &src->delay) || - put_user(status.avail, &src->avail) || - put_user(status.avail_max, &src->avail_max) || - put_user(status.overrange, &src->overrange) || - put_user(status.suspended_state, &src->suspended_state) || - put_user(status.audio_tstamp_data, &src->audio_tstamp_data) || - compat_put_timespec(&status.audio_tstamp, &src->audio_tstamp) || - compat_put_timespec(&status.driver_tstamp, &src->driver_tstamp) || - put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy)) - return -efault; - - return err; -} - -#ifdef config_x86_x32 -/* x32 abi has 64bit timespec and 64bit alignment */ -struct snd_pcm_status_x32 { - s32 state; - u32 rsvd; /* alignment */ - struct timespec trigger_tstamp; - struct timespec tstamp; + u8 rsvd[4]; /* alignment */ + s64 trigger_tstamp_sec; + s64 trigger_tstamp_nsec; + s64 tstamp_sec; + s64 tstamp_nsec; - struct timespec audio_tstamp; - struct timespec driver_tstamp; + s64 audio_tstamp_sec; + s64 audio_tstamp_nsec; + s64 driver_tstamp_sec; + s64 driver_tstamp_nsec; - unsigned char reserved[52-2*sizeof(struct timespec)]; + unsigned char reserved[52-4*sizeof(s64)]; -static int snd_pcm_status_user_x32(struct snd_pcm_substream *substream, - struct snd_pcm_status_x32 __user *src, - bool ext) +static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream, + struct compat_snd_pcm_status64 __user *src, + bool ext) - struct snd_pcm_status status; + struct snd_pcm_status64 status; + struct compat_snd_pcm_status64 compat_status64; + memset(&compat_status64, 0, sizeof(compat_status64)); - err = snd_pcm_status(substream, &status); + err = snd_pcm_status64(substream, &status); - if (put_user(status.state, &src->state) || - put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || - put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.appl_ptr, &src->appl_ptr) || - put_user(status.hw_ptr, &src->hw_ptr) || - put_user(status.delay, &src->delay) || - put_user(status.avail, &src->avail) || - put_user(status.avail_max, &src->avail_max) || - put_user(status.overrange, &src->overrange) || - put_user(status.suspended_state, &src->suspended_state) || - put_user(status.audio_tstamp_data, &src->audio_tstamp_data) || - put_timespec(&status.audio_tstamp, &src->audio_tstamp) || - put_timespec(&status.driver_tstamp, &src->driver_tstamp) || - put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy)) + + compat_status64 = (struct compat_snd_pcm_status64) { + .state = status.state, + .trigger_tstamp_sec = status.trigger_tstamp_sec, + .trigger_tstamp_nsec = status.trigger_tstamp_nsec, + .tstamp_sec = status.tstamp_sec, + .tstamp_nsec = status.tstamp_nsec, + .appl_ptr = status.appl_ptr, + .hw_ptr = status.hw_ptr, + .delay = status.delay, + .avail = status.avail, + .avail_max = status.avail_max, + .overrange = status.overrange, + .suspended_state = status.suspended_state, + .audio_tstamp_data = status.audio_tstamp_data, + .audio_tstamp_sec = status.audio_tstamp_sec, + .audio_tstamp_nsec = status.audio_tstamp_nsec, + .driver_tstamp_sec = status.audio_tstamp_sec, + .driver_tstamp_nsec = status.audio_tstamp_nsec, + .audio_tstamp_accuracy = status.audio_tstamp_accuracy, + }; + + if (copy_to_user(src, &compat_status64, sizeof(compat_status64))) -#endif /* config_x86_x32 */ - sndrv_pcm_ioctl_status32 = _ior('a', 0x20, struct snd_pcm_status32), - sndrv_pcm_ioctl_status_ext32 = _iowr('a', 0x24, struct snd_pcm_status32), + sndrv_pcm_ioctl_status_compat32 = _ior('a', 0x20, struct snd_pcm_status32), + sndrv_pcm_ioctl_status_ext_compat32 = _iowr('a', 0x24, struct snd_pcm_status32), + sndrv_pcm_ioctl_status_compat64 = _ior('a', 0x20, struct compat_snd_pcm_status64), + sndrv_pcm_ioctl_status_ext_compat64 = _iowr('a', 0x24, struct compat_snd_pcm_status64), - sndrv_pcm_ioctl_status_x32 = _ior('a', 0x20, struct snd_pcm_status_x32), - sndrv_pcm_ioctl_status_ext_x32 = _iowr('a', 0x24, struct snd_pcm_status_x32), - case sndrv_pcm_ioctl_status32: - return snd_pcm_status_user_compat(substream, argp, false); - case sndrv_pcm_ioctl_status_ext32: - return snd_pcm_status_user_compat(substream, argp, true); + case sndrv_pcm_ioctl_status_compat32: + return snd_pcm_status_user32(substream, argp, false); + case sndrv_pcm_ioctl_status_ext_compat32: + return snd_pcm_status_user32(substream, argp, true); + case sndrv_pcm_ioctl_status_compat64: + return snd_pcm_status_user_compat64(substream, argp, false); + case sndrv_pcm_ioctl_status_ext_compat64: + return snd_pcm_status_user_compat64(substream, argp, true); - case sndrv_pcm_ioctl_status_x32: - return snd_pcm_status_user_x32(substream, argp, false); - case sndrv_pcm_ioctl_status_ext_x32: - return snd_pcm_status_user_x32(substream, argp, true); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c -int snd_pcm_status(struct snd_pcm_substream *substream, - struct snd_pcm_status *status) +int snd_pcm_status64(struct snd_pcm_substream *substream, + struct snd_pcm_status64 *status) - status->trigger_tstamp = timespec64_to_timespec(runtime->trigger_tstamp); + status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; + status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; - status->tstamp = runtime->status->tstamp; - status->driver_tstamp = timespec64_to_timespec(runtime->driver_tstamp); - status->audio_tstamp = - runtime->status->audio_tstamp; + status->tstamp_sec = runtime->status->tstamp.tv_sec; + status->tstamp_nsec = + runtime->status->tstamp.tv_nsec; + status->driver_tstamp_sec = + runtime->driver_tstamp.tv_sec; + status->driver_tstamp_nsec = + runtime->driver_tstamp.tv_nsec; + status->audio_tstamp_sec = + runtime->status->audio_tstamp.tv_sec; + status->audio_tstamp_nsec = + runtime->status->audio_tstamp.tv_nsec; - status->tstamp = timespec64_to_timespec(tstamp); + status->tstamp_sec = tstamp.tv_sec; + status->tstamp_nsec = tstamp.tv_nsec; -static int snd_pcm_status_user(struct snd_pcm_substream *substream, - struct snd_pcm_status __user * _status, - bool ext) +static int snd_pcm_status_user64(struct snd_pcm_substream *substream, + struct snd_pcm_status64 __user * _status, + bool ext) - struct snd_pcm_status status; + struct snd_pcm_status64 status; - res = snd_pcm_status(substream, &status); + res = snd_pcm_status64(substream, &status); +static int snd_pcm_status_user32(struct snd_pcm_substream *substream, + struct snd_pcm_status32 __user * _status, + bool ext) +{ + struct snd_pcm_status64 status64; + struct snd_pcm_status32 status32; + int res; + + memset(&status64, 0, sizeof(status64)); + memset(&status32, 0, sizeof(status32)); + /* + * with extension, parameters are read/write, + * get audio_tstamp_data from user, + * ignore rest of status structure + */ + if (ext && get_user(status64.audio_tstamp_data, + (u32 __user *)(&_status->audio_tstamp_data))) + return -efault; + res = snd_pcm_status64(substream, &status64); + if (res < 0) + return res; + + status32 = (struct snd_pcm_status32) { + .state = status64.state, + .trigger_tstamp_sec = status64.trigger_tstamp_sec, + .trigger_tstamp_nsec = status64.trigger_tstamp_nsec, + .tstamp_sec = status64.tstamp_sec, + .tstamp_nsec = status64.tstamp_nsec, + .appl_ptr = status64.appl_ptr, + .hw_ptr = status64.hw_ptr, + .delay = status64.delay, + .avail = status64.avail, + .avail_max = status64.avail_max, + .overrange = status64.overrange, + .suspended_state = status64.suspended_state, + .audio_tstamp_data = status64.audio_tstamp_data, + .audio_tstamp_sec = status64.audio_tstamp_sec, + .audio_tstamp_nsec = status64.audio_tstamp_nsec, + .driver_tstamp_sec = status64.audio_tstamp_sec, + .driver_tstamp_nsec = status64.audio_tstamp_nsec, + .audio_tstamp_accuracy = status64.audio_tstamp_accuracy, + }; + + if (copy_to_user(_status, &status32, sizeof(status32))) + return -efault; + + return 0; +} + - case sndrv_pcm_ioctl_status: - return snd_pcm_status_user(substream, arg, false); - case sndrv_pcm_ioctl_status_ext: - return snd_pcm_status_user(substream, arg, true); + case sndrv_pcm_ioctl_status32: + return snd_pcm_status_user32(substream, arg, false); + case sndrv_pcm_ioctl_status_ext32: + return snd_pcm_status_user32(substream, arg, true); + case sndrv_pcm_ioctl_status64: + return snd_pcm_status_user64(substream, arg, false); + case sndrv_pcm_ioctl_status_ext64: + return snd_pcm_status_user64(substream, arg, true);
Audio
3ddee7f88aaf2dee38f7016ac8fd48dd9fdb43e3
baolin wang
sound
core
sound
alsa: avoid using timespec for struct snd_rawmidi_status
the struct snd_rawmidi_status will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h', 'c']
3
128
94
--- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h +#ifndef __kernel__ + __time_pad pad1; +#endif diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c +struct snd_rawmidi_status32 { + s32 stream; + s32 tstamp_sec; /* timestamp */ + s32 tstamp_nsec; + u32 avail; /* available bytes */ + u32 xruns; /* count of overruns since last status (in bytes) */ + unsigned char reserved[16]; /* reserved for future use */ +}; + +#define sndrv_rawmidi_ioctl_status32 _iowr('w', 0x20, struct snd_rawmidi_status32) + +struct snd_rawmidi_status64 { + int stream; + u8 rsvd[4]; /* alignment */ + s64 tstamp_sec; /* timestamp */ + s64 tstamp_nsec; + size_t avail; /* available bytes */ + size_t xruns; /* count of overruns since last status (in bytes) */ + unsigned char reserved[16]; /* reserved for future use */ +}; + +#define sndrv_rawmidi_ioctl_status64 _iowr('w', 0x20, struct snd_rawmidi_status64) + - struct snd_rawmidi_status *status) + struct snd_rawmidi_status64 *status) - struct snd_rawmidi_status *status) + struct snd_rawmidi_status64 *status) +static int snd_rawmidi_ioctl_status32(struct snd_rawmidi_file *rfile, + struct snd_rawmidi_status32 __user *argp) +{ + int err = 0; + struct snd_rawmidi_status32 __user *status = argp; + struct snd_rawmidi_status32 status32; + struct snd_rawmidi_status64 status64; + + if (copy_from_user(&status32, argp, + sizeof(struct snd_rawmidi_status32))) + return -efault; + + switch (status32.stream) { + case sndrv_rawmidi_stream_output: + if (rfile->output == null) + return -einval; + err = snd_rawmidi_output_status(rfile->output, &status64); + break; + case sndrv_rawmidi_stream_input: + if (rfile->input == null) + return -einval; + err = snd_rawmidi_input_status(rfile->input, &status64); + break; + default: + return -einval; + } + if (err < 0) + return err; + + status32 = (struct snd_rawmidi_status32) { + .stream = status64.stream, + .tstamp_sec = status64.tstamp_sec, + .tstamp_nsec = status64.tstamp_nsec, + .avail = status64.avail, + .xruns = status64.xruns, + }; + + if (copy_to_user(status, &status32, sizeof(*status))) + return -efault; + + return 0; +} + +static int snd_rawmidi_ioctl_status64(struct snd_rawmidi_file *rfile, + struct snd_rawmidi_status64 __user *argp) +{ + int err = 0; + struct snd_rawmidi_status64 status; + + if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status64))) + return -efault; + + switch (status.stream) { + case sndrv_rawmidi_stream_output: + if (rfile->output == null) + return -einval; + err = snd_rawmidi_output_status(rfile->output, &status); + break; + case sndrv_rawmidi_stream_input: + if (rfile->input == null) + return -einval; + err = snd_rawmidi_input_status(rfile->input, &status); + break; + default: + return -einval; + } + if (err < 0) + return err; + if (copy_to_user(argp, &status, + sizeof(struct snd_rawmidi_status64))) + return -efault; + return 0; +} + - case sndrv_rawmidi_ioctl_status: - { - int err = 0; - struct snd_rawmidi_status status; - - if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status))) - return -efault; - switch (status.stream) { - case sndrv_rawmidi_stream_output: - if (rfile->output == null) - return -einval; - err = snd_rawmidi_output_status(rfile->output, &status); - break; - case sndrv_rawmidi_stream_input: - if (rfile->input == null) - return -einval; - err = snd_rawmidi_input_status(rfile->input, &status); - break; - default: - return -einval; - } - if (err < 0) - return err; - if (copy_to_user(argp, &status, sizeof(struct snd_rawmidi_status))) - return -efault; - return 0; - } + case sndrv_rawmidi_ioctl_status32: + return snd_rawmidi_ioctl_status32(rfile, argp); + case sndrv_rawmidi_ioctl_status64: + return snd_rawmidi_ioctl_status64(rfile, argp); diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c --- a/sound/core/rawmidi_compat.c +++ b/sound/core/rawmidi_compat.c -struct snd_rawmidi_status32 { +struct compat_snd_rawmidi_status64 { - struct compat_timespec tstamp; + u8 rsvd[4]; /* alignment */ + s64 tstamp_sec; + s64 tstamp_nsec; -static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile, - struct snd_rawmidi_status32 __user *src) +static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile, + struct compat_snd_rawmidi_status64 __user *src) - struct snd_rawmidi_status status; + struct snd_rawmidi_status64 status; + struct compat_snd_rawmidi_status64 compat_status; - if (compat_put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.avail, &src->avail) || - put_user(status.xruns, &src->xruns)) - return -efault; - - return 0; -} - -#ifdef config_x86_x32 -/* x32 abi has 64bit timespec and 64bit alignment */ -struct snd_rawmidi_status_x32 { - s32 stream; - u32 rsvd; /* alignment */ - struct timespec tstamp; - u32 avail; - u32 xruns; - unsigned char reserved[16]; -} __attribute__((packed)); - -#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst)) - -static int snd_rawmidi_ioctl_status_x32(struct snd_rawmidi_file *rfile, - struct snd_rawmidi_status_x32 __user *src) -{ - int err; - struct snd_rawmidi_status status; - - if (get_user(status.stream, &src->stream)) - return -efault; - - switch (status.stream) { - case sndrv_rawmidi_stream_output: - if (!rfile->output) - return -einval; - err = snd_rawmidi_output_status(rfile->output, &status); - break; - case sndrv_rawmidi_stream_input: - if (!rfile->input) - return -einval; - err = snd_rawmidi_input_status(rfile->input, &status); - break; - default: - return -einval; - } - if (err < 0) - return err; + compat_status = (struct compat_snd_rawmidi_status64) { + .stream = status.stream, + .tstamp_sec = status.tstamp_sec, + .tstamp_nsec = status.tstamp_nsec, + .avail = status.avail, + .xruns = status.xruns, + }; - if (put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.avail, &src->avail) || - put_user(status.xruns, &src->xruns)) + if (copy_to_user(src, &compat_status, sizeof(*src))) -#endif /* config_x86_x32 */ - sndrv_rawmidi_ioctl_status32 = _iowr('w', 0x20, struct snd_rawmidi_status32), -#ifdef config_x86_x32 - sndrv_rawmidi_ioctl_status_x32 = _iowr('w', 0x20, struct snd_rawmidi_status_x32), -#endif /* config_x86_x32 */ + sndrv_rawmidi_ioctl_status_compat32 = _iowr('w', 0x20, struct snd_rawmidi_status32), + sndrv_rawmidi_ioctl_status_compat64 = _iowr('w', 0x20, struct compat_snd_rawmidi_status64), - case sndrv_rawmidi_ioctl_status32: - return snd_rawmidi_ioctl_status_compat(rfile, argp); -#ifdef config_x86_x32 - case sndrv_rawmidi_ioctl_status_x32: - return snd_rawmidi_ioctl_status_x32(rfile, argp); -#endif /* config_x86_x32 */ + case sndrv_rawmidi_ioctl_status_compat32: + return snd_rawmidi_ioctl_status32(rfile, argp); + case sndrv_rawmidi_ioctl_status_compat64: + return snd_rawmidi_ioctl_status_compat64(rfile, argp);
Audio
d9e5582c4bb219f3459e39f65410f0e5128fbe91
baolin wang
sound
core
sound
alsa: avoid using timespec for struct snd_timer_tread
the struct snd_timer_tread will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h', 'c']
3
131
39
--- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h -#define sndrv_timer_ioctl_tread _iow('t', 0x02, int) +#define sndrv_timer_ioctl_tread_old _iow('t', 0x02, int) +#define sndrv_timer_ioctl_tread64 _iow('t', 0xa4, int) + +#if __bits_per_long == 64 +#define sndrv_timer_ioctl_tread sndrv_timer_ioctl_tread_old +#else +#define sndrv_timer_ioctl_tread ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? \ + sndrv_timer_ioctl_tread_old : \ + sndrv_timer_ioctl_tread64) +#endif +#ifndef __kernel__ + __time_pad pad1; + __time_pad pad2; +#endif diff --git a/sound/core/timer.c b/sound/core/timer.c --- a/sound/core/timer.c +++ b/sound/core/timer.c +enum timer_tread_format { + tread_format_none = 0, + tread_format_time64, + tread_format_time32, +}; + +struct snd_timer_tread32 { + int event; + s32 tstamp_sec; + s32 tstamp_nsec; + unsigned int val; +}; + +struct snd_timer_tread64 { + int event; + u8 pad1[4]; + s64 tstamp_sec; + s64 tstamp_nsec; + unsigned int val; + u8 pad2[4]; +}; + - struct snd_timer_tread *tqueue; + struct snd_timer_tread64 *tqueue; - struct snd_timer_tread *tread) + struct snd_timer_tread64 *tread) - struct snd_timer_tread r1; + struct snd_timer_tread64 r1; - r1.tstamp = timespec64_to_timespec(*tstamp); + r1.tstamp_sec = tstamp->tv_sec; + r1.tstamp_nsec = tstamp->tv_nsec; - struct snd_timer_tread *r, r1; + struct snd_timer_tread64 *r, r1; - r1.tstamp = timespec64_to_timespec(tstamp); + r1.tstamp_sec = tstamp.tv_sec; + r1.tstamp_nsec = tstamp.tv_nsec; - r->tstamp = timespec64_to_timespec(tstamp); + r->tstamp_sec = tstamp.tv_sec; + r->tstamp_nsec = tstamp.tv_nsec; - r1.tstamp = timespec64_to_timespec(tstamp); + r1.tstamp_sec = tstamp.tv_sec; + r1.tstamp_nsec = tstamp.tv_nsec; - struct snd_timer_tread *tqueue = null; + struct snd_timer_tread64 *tqueue = null; - struct snd_timer_tread tread; + struct snd_timer_tread64 tread; - tread.tstamp.tv_sec = 0; - tread.tstamp.tv_nsec = 0; + tread.tstamp_sec = 0; + tread.tstamp_nsec = 0; +static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu, + unsigned int cmd, bool compat) +{ + int __user *p = argp; + int xarg, old_tread; + + if (tu->timeri) /* too late */ + return -ebusy; + if (get_user(xarg, p)) + return -efault; + + old_tread = tu->tread; + + if (!xarg) + tu->tread = tread_format_none; + else if (cmd == sndrv_timer_ioctl_tread64 || + (is_enabled(config_64bit) && !compat)) + tu->tread = tread_format_time64; + else + tu->tread = tread_format_time32; + + if (tu->tread != old_tread && + realloc_user_queue(tu, tu->queue_size) < 0) { + tu->tread = old_tread; + return -enomem; + } + + return 0; +} + - unsigned long arg) + unsigned long arg, bool compat) - case sndrv_timer_ioctl_tread: - { - int xarg, old_tread; - - if (tu->timeri) /* too late */ - return -ebusy; - if (get_user(xarg, p)) - return -efault; - old_tread = tu->tread; - tu->tread = xarg ? 1 : 0; - if (tu->tread != old_tread && - realloc_user_queue(tu, tu->queue_size) < 0) { - tu->tread = old_tread; - return -enomem; - } - return 0; - } + case sndrv_timer_ioctl_tread_old: + case sndrv_timer_ioctl_tread64: + return snd_timer_user_tread(argp, tu, cmd, compat); - ret = __snd_timer_user_ioctl(file, cmd, arg); + ret = __snd_timer_user_ioctl(file, cmd, arg, false); + struct snd_timer_tread64 *tread; + struct snd_timer_tread32 tread32; - unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read); + switch (tu->tread) { + case tread_format_time64: + unit = sizeof(struct snd_timer_tread64); + break; + case tread_format_time32: + unit = sizeof(struct snd_timer_tread32); + break; + case tread_format_none: + unit = sizeof(struct snd_timer_read); + break; + default: + warn_once(1, "corrupt snd_timer_user "); + return -enotsupp; + } + - if (tu->tread) { - if (copy_to_user(buffer, &tu->tqueue[qhead], - sizeof(struct snd_timer_tread))) + tread = &tu->tqueue[qhead]; + + switch (tu->tread) { + case tread_format_time64: + if (copy_to_user(buffer, tread, + sizeof(struct snd_timer_tread64))) - } else { + break; + case tread_format_time32: + memset(&tread32, 0, sizeof(tread32)); + tread32 = (struct snd_timer_tread32) { + .event = tread->event, + .tstamp_sec = tread->tstamp_sec, + .tstamp_sec = tread->tstamp_nsec, + .val = tread->val, + }; + + if (copy_to_user(buffer, &tread32, sizeof(tread32))) + err = -efault; + break; + case tread_format_none: + break; + default: + err = -enotsupp; + break; diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c - case sndrv_timer_ioctl_tread: + case sndrv_timer_ioctl_tread_old: + case sndrv_timer_ioctl_tread64: - return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp); + return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp, true);
Audio
07094ae6f9527279de6fd0c59e88f6d0423585b1
baolin wang
sound
core
sound
alsa: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c
this is a preparation patch, moving the compat handler for snd_pcm_ioctl_sync_ptr_compat from pcm_compat.c to pcm_native.c. no other changes are indented.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['c']
2
100
98
--- diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c -/* recalcuate the boundary within 32bit */ -static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) -{ - snd_pcm_uframes_t boundary; - - if (! runtime->buffer_size) - return 0; - boundary = runtime->buffer_size; - while (boundary * 2 <= 0x7ffffffful - runtime->buffer_size) - boundary *= 2; - return boundary; -} - - -struct snd_pcm_mmap_status32 { - s32 state; - s32 pad1; - u32 hw_ptr; - struct compat_timespec tstamp; - s32 suspended_state; - struct compat_timespec audio_tstamp; -} __attribute__((packed)); - -struct snd_pcm_mmap_control32 { - u32 appl_ptr; - u32 avail_min; -}; - -struct snd_pcm_sync_ptr32 { - u32 flags; - union { - struct snd_pcm_mmap_status32 status; - unsigned char reserved[64]; - } s; - union { - struct snd_pcm_mmap_control32 control; - unsigned char reserved[64]; - } c; -} __attribute__((packed)); - -static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, - struct snd_pcm_sync_ptr32 __user *src) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - volatile struct snd_pcm_mmap_status *status; - volatile struct snd_pcm_mmap_control *control; - u32 sflags; - struct snd_pcm_mmap_control scontrol; - struct snd_pcm_mmap_status sstatus; - snd_pcm_uframes_t boundary; - int err; - - if (snd_bug_on(!runtime)) - return -einval; - - if (get_user(sflags, &src->flags) || - get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || - get_user(scontrol.avail_min, &src->c.control.avail_min)) - return -efault; - if (sflags & sndrv_pcm_sync_ptr_hwsync) { - err = snd_pcm_hwsync(substream); - if (err < 0) - return err; - } - status = runtime->status; - control = runtime->control; - boundary = recalculate_boundary(runtime); - if (! boundary) - boundary = 0x7fffffff; - snd_pcm_stream_lock_irq(substream); - /* fixme: we should consider the boundary for the sync from app */ - if (!(sflags & sndrv_pcm_sync_ptr_appl)) - control->appl_ptr = scontrol.appl_ptr; - else - scontrol.appl_ptr = control->appl_ptr % boundary; - if (!(sflags & sndrv_pcm_sync_ptr_avail_min)) - control->avail_min = scontrol.avail_min; - else - scontrol.avail_min = control->avail_min; - sstatus.state = status->state; - sstatus.hw_ptr = status->hw_ptr % boundary; - sstatus.tstamp = status->tstamp; - sstatus.suspended_state = status->suspended_state; - sstatus.audio_tstamp = status->audio_tstamp; - snd_pcm_stream_unlock_irq(substream); - if (put_user(sstatus.state, &src->s.status.state) || - put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || - compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || - put_user(sstatus.suspended_state, &src->s.status.suspended_state) || - compat_put_timespec(&sstatus.audio_tstamp, - &src->s.status.audio_tstamp) || - put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || - put_user(scontrol.avail_min, &src->c.control.avail_min)) - return -efault; - - return 0; -} - diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c +#include <linux/compat.h> +#ifdef config_compat +struct snd_pcm_mmap_status32 { + s32 state; + s32 pad1; + u32 hw_ptr; + struct compat_timespec tstamp; + s32 suspended_state; + struct compat_timespec audio_tstamp; +} __attribute__((packed)); + +struct snd_pcm_mmap_control32 { + u32 appl_ptr; + u32 avail_min; +}; + +struct snd_pcm_sync_ptr32 { + u32 flags; + union { + struct snd_pcm_mmap_status32 status; + unsigned char reserved[64]; + } s; + union { + struct snd_pcm_mmap_control32 control; + unsigned char reserved[64]; + } c; +} __attribute__((packed)); + +/* recalcuate the boundary within 32bit */ +static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) +{ + snd_pcm_uframes_t boundary; + + if (! runtime->buffer_size) + return 0; + boundary = runtime->buffer_size; + while (boundary * 2 <= 0x7ffffffful - runtime->buffer_size) + boundary *= 2; + return boundary; +} + +static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, + struct snd_pcm_sync_ptr32 __user *src) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + volatile struct snd_pcm_mmap_status *status; + volatile struct snd_pcm_mmap_control *control; + u32 sflags; + struct snd_pcm_mmap_control scontrol; + struct snd_pcm_mmap_status sstatus; + snd_pcm_uframes_t boundary; + int err; + + if (snd_bug_on(!runtime)) + return -einval; + + if (get_user(sflags, &src->flags) || + get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || + get_user(scontrol.avail_min, &src->c.control.avail_min)) + return -efault; + if (sflags & sndrv_pcm_sync_ptr_hwsync) { + err = snd_pcm_hwsync(substream); + if (err < 0) + return err; + } + status = runtime->status; + control = runtime->control; + boundary = recalculate_boundary(runtime); + if (! boundary) + boundary = 0x7fffffff; + snd_pcm_stream_lock_irq(substream); + /* fixme: we should consider the boundary for the sync from app */ + if (!(sflags & sndrv_pcm_sync_ptr_appl)) + control->appl_ptr = scontrol.appl_ptr; + else + scontrol.appl_ptr = control->appl_ptr % boundary; + if (!(sflags & sndrv_pcm_sync_ptr_avail_min)) + control->avail_min = scontrol.avail_min; + else + scontrol.avail_min = control->avail_min; + sstatus.state = status->state; + sstatus.hw_ptr = status->hw_ptr % boundary; + sstatus.tstamp = status->tstamp; + sstatus.suspended_state = status->suspended_state; + sstatus.audio_tstamp = status->audio_tstamp; + snd_pcm_stream_unlock_irq(substream); + if (put_user(sstatus.state, &src->s.status.state) || + put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || + compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || + put_user(sstatus.suspended_state, &src->s.status.suspended_state) || + compat_put_timespec(&sstatus.audio_tstamp, + &src->s.status.audio_tstamp) || + put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || + put_user(scontrol.avail_min, &src->c.control.avail_min)) + return -efault; + + return 0; +} +#endif +
Audio
09d94175dbeac12d38b1599a02c7000a5e51b4cb
arnd bergmann
sound
core
alsa: add new 32-bit layout for snd_pcm_mmap_status/control
the snd_pcm_mmap_status and snd_pcm_mmap_control interfaces are one of the trickiest areas to get right when moving to 64-bit time_t in user space.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h', 'c']
4
147
41
- almost all x86 and powerpc users these days are on 64-bit kernels, - it never worked in compat mode (it was intentionally disabled there) - the application already needs to work with a fallback to --- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h +#include <asm/byteorder.h> + - +#if (__bits_per_long == 32 && defined(__use_time_bits64)) || defined __kernel__ +#define __snd_struct_time64 +#endif - sndrv_pcm_mmap_offset_status = 0x80000000, - sndrv_pcm_mmap_offset_control = 0x81000000, + sndrv_pcm_mmap_offset_status_old = 0x80000000, + sndrv_pcm_mmap_offset_control_old = 0x81000000, + sndrv_pcm_mmap_offset_status_new = 0x82000000, + sndrv_pcm_mmap_offset_control_new = 0x83000000, +#ifdef __snd_struct_time64 + sndrv_pcm_mmap_offset_status = sndrv_pcm_mmap_offset_status_new, + sndrv_pcm_mmap_offset_control = sndrv_pcm_mmap_offset_control_new, +#else + sndrv_pcm_mmap_offset_status = sndrv_pcm_mmap_offset_status_old, + sndrv_pcm_mmap_offset_control = sndrv_pcm_mmap_offset_control_old, +#endif -struct snd_pcm_mmap_status { +/* + * for mmap operations, we need the 64-bit layout, both for compat mode, + * and for y2038 compatibility. for 64-bit applications, the two definitions + * are identical, so we keep the traditional version. + */ +#ifdef __snd_struct_time64 +#define __snd_pcm_mmap_status64 snd_pcm_mmap_status +#define __snd_pcm_mmap_control64 snd_pcm_mmap_control +#define __snd_pcm_sync_ptr64 snd_pcm_sync_ptr +#ifdef __kernel__ +#define __snd_timespec64 __kernel_timespec +#else +#define __snd_timespec64 timespec +#endif +struct __snd_timespec { + __s32 tv_sec; + __s32 tv_nsec; +}; +#else +#define __snd_pcm_mmap_status snd_pcm_mmap_status +#define __snd_pcm_mmap_control snd_pcm_mmap_control +#define __snd_pcm_sync_ptr snd_pcm_sync_ptr +#define __snd_timespec timespec +struct __snd_timespec64 { + __s64 tv_sec; + __s64 tv_nsec; +}; + +#endif + +struct __snd_pcm_mmap_status { - struct timespec tstamp; /* timestamp */ + struct __snd_timespec tstamp; /* timestamp */ - struct timespec audio_tstamp; /* from sample counter or wall clock */ + struct __snd_timespec audio_tstamp; /* from sample counter or wall clock */ -struct snd_pcm_mmap_control { +struct __snd_pcm_mmap_control { -struct snd_pcm_sync_ptr { +struct __snd_pcm_sync_ptr { - struct snd_pcm_mmap_status status; + struct __snd_pcm_mmap_status status; + unsigned char reserved[64]; + } s; + union { + struct __snd_pcm_mmap_control control; + unsigned char reserved[64]; + } c; +}; + +#if defined(__byte_order) ? __byte_order == __big_endian : defined(__big_endian) +typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; +typedef char __pad_after_uframe[0]; +#endif + +#if defined(__byte_order) ? __byte_order == __little_endian : defined(__little_endian) +typedef char __pad_before_uframe[0]; +typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; +#endif + +struct __snd_pcm_mmap_status64 { + __s32 state; /* ro: state - sndrv_pcm_state_xxxx */ + __u32 pad1; /* needed for 64 bit alignment */ + __pad_before_uframe __pad1; + snd_pcm_uframes_t hw_ptr; /* ro: hw ptr (0...boundary-1) */ + __pad_after_uframe __pad2; + struct __snd_timespec64 tstamp; /* timestamp */ + __s32 suspended_state; /* ro: suspended stream state */ + __u32 pad3; /* needed for 64 bit alignment */ + struct __snd_timespec64 audio_tstamp; /* sample counter or wall clock */ +}; + +struct __snd_pcm_mmap_control64 { + __pad_before_uframe __pad1; + snd_pcm_uframes_t appl_ptr; /* rw: appl ptr (0...boundary-1) */ + __pad_before_uframe __pad2; + + __pad_before_uframe __pad3; + snd_pcm_uframes_t avail_min; /* rw: min available frames for wakeup */ + __pad_after_uframe __pad4; +}; + +struct __snd_pcm_sync_ptr64 { + __u32 flags; + __u32 pad1; + union { + struct __snd_pcm_mmap_status64 status; - struct snd_pcm_mmap_control control; + struct __snd_pcm_mmap_control64 control; +#define __sndrv_pcm_ioctl_sync_ptr _iowr('a', 0x23, struct __snd_pcm_sync_ptr) +#define __sndrv_pcm_ioctl_sync_ptr64 _iowr('a', 0x23, struct __snd_pcm_sync_ptr64) diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c -#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst)) - - struct timespec tstamp; + s64 tstamp_sec; + s64 tstamp_nsec; - struct timespec audio_tstamp; + s64 audio_tstamp_sec; + s64 audio_tstamp_nsec; - put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || + put_user(sstatus.tstamp.tv_sec, &src->s.status.tstamp_sec) || + put_user(sstatus.tstamp.tv_nsec, &src->s.status.tstamp_nsec) || - put_timespec(&sstatus.audio_tstamp, &src->s.status.audio_tstamp) || + put_user(sstatus.audio_tstamp.tv_sec, &src->s.status.audio_tstamp_sec) || + put_user(sstatus.audio_tstamp.tv_nsec, &src->s.status.audio_tstamp_nsec) || - sndrv_pcm_ioctl_sync_ptr32 = _iowr('a', 0x23, struct snd_pcm_sync_ptr32), - * mmap of pcm status/control records because of the size - * incompatibility. + * mmap of the old pcm status/control records because + * of the size incompatibility. + case __sndrv_pcm_ioctl_sync_ptr32: + return snd_pcm_common_ioctl(file, substream, cmd, argp); + case __sndrv_pcm_ioctl_sync_ptr64: +#ifdef config_x86_x32 + if (in_x32_syscall()) + return snd_pcm_ioctl_sync_ptr_x32(substream, argp); +#endif /* config_x86_x32 */ - case sndrv_pcm_ioctl_sync_ptr32: - return snd_pcm_ioctl_sync_ptr_compat(substream, argp); - case sndrv_pcm_ioctl_sync_ptr_x32: - return snd_pcm_ioctl_sync_ptr_x32(substream, argp); diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c - runtime->status->tstamp = timespec64_to_timespec(tstamp); + runtime->status->tstamp.tv_sec = tstamp.tv_sec; + runtime->status->tstamp.tv_nsec = tstamp.tv_nsec; - runtime->status->audio_tstamp = - timespec64_to_timespec(*audio_tstamp); - runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp); + runtime->status->audio_tstamp.tv_sec = audio_tstamp->tv_sec; + runtime->status->audio_tstamp.tv_nsec = audio_tstamp->tv_nsec; + runtime->status->tstamp.tv_sec = curr_tstamp->tv_sec; + runtime->status->tstamp.tv_nsec = curr_tstamp->tv_nsec; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c -#ifdef config_compat - struct compat_timespec tstamp; + s32 tstamp_sec; + s32 tstamp_nsec; - struct compat_timespec audio_tstamp; + s32 audio_tstamp_sec; + s32 audio_tstamp_nsec; - compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || + put_user(sstatus.tstamp.tv_sec, &src->s.status.tstamp_sec) || + put_user(sstatus.tstamp.tv_nsec, &src->s.status.tstamp_nsec) || - compat_put_timespec(&sstatus.audio_tstamp, - &src->s.status.audio_tstamp) || + put_user(sstatus.audio_tstamp.tv_sec, &src->s.status.audio_tstamp_sec) || + put_user(sstatus.audio_tstamp.tv_nsec, &src->s.status.audio_tstamp_nsec) || -#endif +#define __sndrv_pcm_ioctl_sync_ptr32 _iowr('a', 0x23, struct snd_pcm_sync_ptr32) - case sndrv_pcm_ioctl_sync_ptr: + case __sndrv_pcm_ioctl_sync_ptr32: + return snd_pcm_ioctl_sync_ptr_compat(substream, arg); + case __sndrv_pcm_ioctl_sync_ptr64: - if (pcm_file->no_compat_mmap) - return false; - case sndrv_pcm_mmap_offset_status: + case sndrv_pcm_mmap_offset_status_old: + if (pcm_file->no_compat_mmap || !is_enabled(config_64bit)) + return -enxio; + /* fallthrough */ + case sndrv_pcm_mmap_offset_status_new: - case sndrv_pcm_mmap_offset_control: + case sndrv_pcm_mmap_offset_control_old: + if (pcm_file->no_compat_mmap || !is_enabled(config_64bit)) + return -enxio; + /* fallthrough */ + case sndrv_pcm_mmap_offset_control_new: - case sndrv_pcm_mmap_offset_status: + case sndrv_pcm_mmap_offset_status_new: - case sndrv_pcm_mmap_offset_control: + case sndrv_pcm_mmap_offset_control_new:
Audio
80fe7430c7085951d1246d83f638cc17e6c0be36
arnd bergmann
sound
core
sound
alsa: bump uapi version numbers
change sndrv_pcm_version, sndrv_rawmidi_version and sndrv_timer_version to indicate the addition of the time64 version of the mmap interface and these ioctl commands:
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
fix year 2038 issue for sound subsystem
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h']
1
3
3
--- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h -#define sndrv_pcm_version sndrv_protocol_version(2, 0, 14) +#define sndrv_pcm_version sndrv_protocol_version(2, 0, 15) -#define sndrv_rawmidi_version sndrv_protocol_version(2, 0, 0) +#define sndrv_rawmidi_version sndrv_protocol_version(2, 0, 1) -#define sndrv_timer_version sndrv_protocol_version(2, 0, 6) +#define sndrv_timer_version sndrv_protocol_version(2, 0, 7)
Audio
1cfaef9617033f38eba9cc725809ed32bcdb3dc5
arnd bergmann
include
uapi
sound
alsa: cmipci: allow disabling mpu port via module option
patrick may reported that his sound card with cmi8378 chip causes a crash / reboot when accessing the midi port that isn't actually present on the board. moreover, despite of the documentation, passing mpu_port=0 doesn't disable the midi port on this board.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
allow disabling mpu port via module option
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['cmipci']
['c', 'rst']
2
5
3
--- diff --git a/documentation/sound/alsa-configuration.rst b/documentation/sound/alsa-configuration.rst --- a/documentation/sound/alsa-configuration.rst +++ b/documentation/sound/alsa-configuration.rst - 0 = disable (default) + 1 = integrated pci port (default on 8738), + 0 = disable diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c -static long mpu_port[sndrv_cards]; +static long mpu_port[sndrv_cards] = {[0 ... (sndrv_cards-1)] = 1}; - iomidi = cm->iobase + cm_reg_mpu_pci; + if (mpu_port[dev]) + iomidi = cm->iobase + cm_reg_mpu_pci;
Audio
d8cac6207ec1abd3c85cff2625dd3898d59c4df5
takashi iwai
documentation
sound
alsa: control: add verification for kctl accesses
the current implementation of alsa control api fully relies on the callbacks of each driver, and there is no verification of the values passed via api. this patch is an attempt to improve the situation slightly by adding the validation code for the values stored via info and get callbacks.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add verification for kctl accesses
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['control']
['h', 'kconfig', 'c']
5
268
39
- whether the info type is valid - whether the number of enum items is non-zero - whether the given info count is within the allowed boundary - whether the values are within the given range - whether the values are aligned with the given step - whether any further changes are seen in the data array over the --- diff --git a/include/sound/control.h b/include/sound/control.h --- a/include/sound/control.h +++ b/include/sound/control.h +/* internal flag for skipping validations */ +#ifdef config_snd_ctl_validation +#define sndrv_ctl_elem_access_skip_check (1 << 27) +#define snd_ctl_skip_validation(info) \ + ((info)->access & sndrv_ctl_elem_access_skip_check) +#else +#define sndrv_ctl_elem_access_skip_check 0 +#define snd_ctl_skip_validation(info) true +#endif + diff --git a/sound/core/kconfig b/sound/core/kconfig --- a/sound/core/kconfig +++ b/sound/core/kconfig +config snd_ctl_validation + bool "perform sanity-checks for each control element access" + depends on snd_debug + help + say y to enable the additional validation of each control element + access, including sanity-checks like whether the values returned + from the driver are in the proper ranges or the check of the invalid + access at out-of-array areas. + diff --git a/sound/core/control.c b/sound/core/control.c --- a/sound/core/control.c +++ b/sound/core/control.c +#include <linux/math64.h> - sndrv_ctl_elem_access_tlv_callback); + sndrv_ctl_elem_access_tlv_callback | + sndrv_ctl_elem_access_skip_check); -static int snd_ctl_elem_info(struct snd_ctl_file *ctl, - struct snd_ctl_elem_info *info) +/* check whether the given kctl info is valid */ +static int snd_ctl_check_elem_info(struct snd_card *card, + const struct snd_ctl_elem_info *info) +{ + static const unsigned int max_value_counts[] = { + [sndrv_ctl_elem_type_boolean] = 128, + [sndrv_ctl_elem_type_integer] = 128, + [sndrv_ctl_elem_type_enumerated] = 128, + [sndrv_ctl_elem_type_bytes] = 512, + [sndrv_ctl_elem_type_iec958] = 1, + [sndrv_ctl_elem_type_integer64] = 64, + }; + + if (info->type < sndrv_ctl_elem_type_boolean || + info->type > sndrv_ctl_elem_type_integer64) { + if (card) + dev_err(card->dev, + "control %i:%i:%i:%s:%i: invalid type %d ", + info->id.iface, info->id.device, + info->id.subdevice, info->id.name, + info->id.index, info->type); + return -einval; + } + if (info->type == sndrv_ctl_elem_type_enumerated && + info->value.enumerated.items == 0) { + if (card) + dev_err(card->dev, + "control %i:%i:%i:%s:%i: zero enum items ", + info->id.iface, info->id.device, + info->id.subdevice, info->id.name, + info->id.index); + return -einval; + } + if (info->count > max_value_counts[info->type]) { + if (card) + dev_err(card->dev, + "control %i:%i:%i:%s:%i: invalid count %d ", + info->id.iface, info->id.device, + info->id.subdevice, info->id.name, + info->id.index, info->count); + return -einval; + } + + return 0; +} + +/* the capacity of struct snd_ctl_elem_value.value.*/ +static const unsigned int value_sizes[] = { + [sndrv_ctl_elem_type_boolean] = sizeof(long), + [sndrv_ctl_elem_type_integer] = sizeof(long), + [sndrv_ctl_elem_type_enumerated] = sizeof(unsigned int), + [sndrv_ctl_elem_type_bytes] = sizeof(unsigned char), + [sndrv_ctl_elem_type_iec958] = sizeof(struct snd_aes_iec958), + [sndrv_ctl_elem_type_integer64] = sizeof(long long), +}; + +#ifdef config_snd_ctl_validation +/* fill the remaining snd_ctl_elem_value data with the given pattern */ +static void fill_remaining_elem_value(struct snd_ctl_elem_value *control, + struct snd_ctl_elem_info *info, + u32 pattern) +{ + size_t offset = value_sizes[info->type] * info->count; + + offset = (offset + sizeof(u32) - 1) / sizeof(u32); + memset32((u32 *)control->value.bytes.data + offset, pattern, + sizeof(control->value) / sizeof(u32) - offset); +} + +/* check whether the given integer ctl value is valid */ +static int sanity_check_int_value(struct snd_card *card, + const struct snd_ctl_elem_value *control, + const struct snd_ctl_elem_info *info, + int i) +{ + long long lval, lmin, lmax, lstep; + u64 rem; + + switch (info->type) { + default: + case sndrv_ctl_elem_type_boolean: + lval = control->value.integer.value[i]; + lmin = 0; + lmax = 1; + lstep = 0; + break; + case sndrv_ctl_elem_type_integer: + lval = control->value.integer.value[i]; + lmin = info->value.integer.min; + lmax = info->value.integer.max; + lstep = info->value.integer.step; + break; + case sndrv_ctl_elem_type_integer64: + lval = control->value.integer64.value[i]; + lmin = info->value.integer64.min; + lmax = info->value.integer64.max; + lstep = info->value.integer64.step; + break; + case sndrv_ctl_elem_type_enumerated: + lval = control->value.enumerated.item[i]; + lmin = 0; + lmax = info->value.enumerated.items - 1; + lstep = 0; + break; + } + + if (lval < lmin || lval > lmax) { + dev_err(card->dev, + "control %i:%i:%i:%s:%i: value out of range %lld (%lld/%lld) at count %i ", + control->id.iface, control->id.device, + control->id.subdevice, control->id.name, + control->id.index, lval, lmin, lmax, i); + return -einval; + } + if (lstep) { + div64_u64_rem(lval, lstep, &rem); + if (rem) { + dev_err(card->dev, + "control %i:%i:%i:%s:%i: unaligned value %lld (step %lld) at count %i ", + control->id.iface, control->id.device, + control->id.subdevice, control->id.name, + control->id.index, lval, lstep, i); + return -einval; + } + } + + return 0; +} + +/* perform sanity checks to the given snd_ctl_elem_value object */ +static int sanity_check_elem_value(struct snd_card *card, + const struct snd_ctl_elem_value *control, + const struct snd_ctl_elem_info *info, + u32 pattern) +{ + size_t offset; + int i, ret; + u32 *p; + + switch (info->type) { + case sndrv_ctl_elem_type_boolean: + case sndrv_ctl_elem_type_integer: + case sndrv_ctl_elem_type_integer64: + case sndrv_ctl_elem_type_enumerated: + for (i = 0; i < info->count; i++) { + ret = sanity_check_int_value(card, control, info, i); + if (ret < 0) + return ret; + } + break; + default: + break; + } + + /* check whether the remaining area kept untouched */ + offset = value_sizes[info->type] * info->count; + offset = (offset + sizeof(u32) - 1) / sizeof(u32); + p = (u32 *)control->value.bytes.data + offset; + for (; offset < sizeof(control->value) / sizeof(u32); offset++, p++) { + if (*p != pattern) { + ret = -einval; + break; + } + *p = 0; /* clear the checked area */ + } + + return ret; +} +#else +static inline void fill_remaining_elem_value(struct snd_ctl_elem_value *control, + struct snd_ctl_elem_info *info, + u32 pattern) +{ +} + +static inline int sanity_check_elem_value(struct snd_card *card, + struct snd_ctl_elem_value *control, + struct snd_ctl_elem_info *info, + u32 pattern) +{ + return 0; +} +#endif + +static int __snd_ctl_elem_info(struct snd_card *card, + struct snd_kcontrol *kctl, + struct snd_ctl_elem_info *info, + struct snd_ctl_file *ctl) - struct snd_card *card = ctl->card; - struct snd_kcontrol *kctl; - down_read(&card->controls_rwsem); - kctl = snd_ctl_find_id(card, &info->id); - if (kctl == null) { - up_read(&card->controls_rwsem); - return -enoent; - } + if (!snd_ctl_skip_validation(info) && + snd_ctl_check_elem_info(card, info) < 0) + result = -einval; + return result; +} + +static int snd_ctl_elem_info(struct snd_ctl_file *ctl, + struct snd_ctl_elem_info *info) +{ + struct snd_card *card = ctl->card; + struct snd_kcontrol *kctl; + int result; + + down_read(&card->controls_rwsem); + kctl = snd_ctl_find_id(card, &info->id); + if (kctl == null) + result = -enoent; + else + result = __snd_ctl_elem_info(card, kctl, info, ctl); + /* drop internal access flags */ + info.access &= ~sndrv_ctl_elem_access_skip_check; + struct snd_ctl_elem_info info; + const u32 pattern = 0xdeadbeef; + int ret; - return kctl->get(kctl, control); + +#ifdef config_snd_ctl_validation + /* info is needed only for validation */ + memset(&info, 0, sizeof(info)); + info.id = control->id; + ret = __snd_ctl_elem_info(card, kctl, &info, null); + if (ret < 0) + return ret; +#endif + + if (!snd_ctl_skip_validation(&info)) + fill_remaining_elem_value(control, &info, pattern); + ret = kctl->get(kctl, control); + if (ret < 0) + return ret; + if (!snd_ctl_skip_validation(&info) && + sanity_check_elem_value(card, control, &info, pattern) < 0) { + dev_err(card->dev, + "control %i:%i:%i:%s:%i: access overflow ", + control->id.iface, control->id.device, + control->id.subdevice, control->id.name, + control->id.index); + return -einval; + } + return ret; - /* the capacity of struct snd_ctl_elem_value.value.*/ - static const unsigned int value_sizes[] = { - [sndrv_ctl_elem_type_boolean] = sizeof(long), - [sndrv_ctl_elem_type_integer] = sizeof(long), - [sndrv_ctl_elem_type_enumerated] = sizeof(unsigned int), - [sndrv_ctl_elem_type_bytes] = sizeof(unsigned char), - [sndrv_ctl_elem_type_iec958] = sizeof(struct snd_aes_iec958), - [sndrv_ctl_elem_type_integer64] = sizeof(long long), - }; - static const unsigned int max_value_counts[] = { - [sndrv_ctl_elem_type_boolean] = 128, - [sndrv_ctl_elem_type_integer] = 128, - [sndrv_ctl_elem_type_enumerated] = 128, - [sndrv_ctl_elem_type_bytes] = 512, - [sndrv_ctl_elem_type_iec958] = 1, - [sndrv_ctl_elem_type_integer64] = 64, - }; - if (info->type < sndrv_ctl_elem_type_boolean || - info->type > sndrv_ctl_elem_type_integer64) - return -einval; - if (info->type == sndrv_ctl_elem_type_enumerated && - info->value.enumerated.items == 0) - return -einval; - if (info->count < 1 || - info->count > max_value_counts[info->type]) + /* pass null to card for suppressing error messages */ + err = snd_ctl_check_elem_info(null, info); + if (err < 0) + return err; + /* user-space control doesn't allow zero-size data */ + if (info->count < 1) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c - sizeof(ucontrol->value.integer.value)); + sizeof(long) * info->max_channels); diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c - .access = sndrv_ctl_elem_access_read | sndrv_ctl_elem_access_volatile, + .access = sndrv_ctl_elem_access_read | sndrv_ctl_elem_access_volatile | + sndrv_ctl_elem_access_skip_check,
Audio
fbd3eb7f66c5b4f37a959bc2deaeb1d7b5ddf0d4
takashi iwai
sound
core
hda
alsa: dice: add support for alesis mastercontrol
alesis mastercontrol was shipped 2009 and already discontinued. this model consists of: * tsb41ab2 for physical layer of ieee 1394 * wavefront dice ii std for link layer and protocol implementation * freescale dspb56374ae
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for alesis mastercontrol
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['dice']
['c', 'h']
3
33
0
----------------------------------------------------------------- ----------------------------------------------------------------- ----------------------------------------------------------------- ----------------------------------------------------------------- ----------------------------------------------------------------- ----------------------------------------------------------------- --- diff --git a/sound/firewire/dice/dice-alesis.c b/sound/firewire/dice/dice-alesis.c --- a/sound/firewire/dice/dice-alesis.c +++ b/sound/firewire/dice/dice-alesis.c + +int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice) +{ + int i; + + dice->tx_pcm_chs[0][snd_dice_rate_mode_low] = 16; + dice->tx_pcm_chs[1][snd_dice_rate_mode_low] = 12; + dice->tx_pcm_chs[0][snd_dice_rate_mode_middle] = 12; + dice->tx_pcm_chs[1][snd_dice_rate_mode_middle] = 4; + dice->tx_pcm_chs[0][snd_dice_rate_mode_high] = 8; + dice->tx_pcm_chs[1][snd_dice_rate_mode_high] = 0; + + for (i = 0; i < snd_dice_rate_mode_count; ++i) { + dice->rx_pcm_chs[0][i] = 6; + dice->rx_pcm_chs[1][i] = 0; + } + + for (i = 0; i < max_streams; ++i) { + dice->tx_midi_ports[i] = 2; + dice->rx_midi_ports[i] = 2; + } + + return 0; +} diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c --- a/sound/firewire/dice/dice.c +++ b/sound/firewire/dice/dice.c + // alesis mastercontrol. + { + .match_flags = ieee1394_match_vendor_id | + ieee1394_match_model_id, + .vendor_id = oui_alesis, + .model_id = 0x000002, + .driver_data = (kernel_ulong_t)snd_dice_detect_alesis_mastercontrol_formats, + }, diff --git a/sound/firewire/dice/dice.h b/sound/firewire/dice/dice.h --- a/sound/firewire/dice/dice.h +++ b/sound/firewire/dice/dice.h +int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice);
Audio
791a485f2da392df00341ed4c0c14780fd320d92
takashi sakamoto
sound
firewire
dice
alsa: ctl: remove unused macro for timestamping of elem_value
in a former commit, 'tstamp' member was removed from 'struct snd_ctl_elem_value' in a middle way toward solution of y2038 issue. in a protocol of alsa control interface, this member is designed to deliver timestamp information in the value structure when the target element supports sndrv_ctl_elem_access_timestamp flag.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
the already deprecated dimension support in alsa control api is dropped completely now
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h']
1
1
1
--- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h -#define sndrv_ctl_elem_access_timestamp (1<<3) /* when was control changed */ +// (1 << 3) is unused.
Audio
54228356667920658cd33a63e12b7bff3e13c880
takashi sakamoto
include
uapi
sound
alsa: pci: echoaudio: remove usage of dimen menber of elem_value structure
in a couple of years ago, 'echomixer' userspace application was revised not to use 'dimen' member of 'struct snd_ctl_elem_info'.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
the already deprecated dimension support in alsa control api is dropped completely now
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['c']
1
0
11
--- diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c - uinfo->dimen.d[0] = num_busses_out(chip); - uinfo->dimen.d[1] = num_busses_in(chip); - uinfo->dimen.d[0] = num_busses_out(chip); - uinfo->dimen.d[1] = num_pipes_out(chip); -#ifdef echocard_has_vmixer - uinfo->dimen.d[0] = 3; /* out, in, virt */ -#else - uinfo->dimen.d[0] = 2; /* out, in */ -#endif - uinfo->dimen.d[1] = 16; /* 16 channels */ - uinfo->dimen.d[2] = 2; /* 0=level, 1=peak */
Audio
e67c3f0fd44c9bbd7a484b7cf6e9bcb4c0a0a858
takashi sakamoto
sound
pci
echoaudio
alsa: ctl: remove dimen member from elem_info structure
the 'dimen' member of 'struct snd_ctl_elem_info' is designed to deliver information to use an array of value as multi-dimensional values. this feature is used just by echoaudio pci driver, and fortunately it's not used by the other applications than 'echomixer' in alsa-tools.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
the already deprecated dimension support in alsa control api is dropped completely now
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h', 'c']
2
1
37
--- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h - union { - unsigned short d[4]; /* dimensions */ - unsigned short *d_ptr; /* indirect - obsoleted */ - } dimen; - unsigned char reserved[64-4*sizeof(unsigned short)]; + unsigned char reserved[64]; diff --git a/sound/core/control.c b/sound/core/control.c --- a/sound/core/control.c +++ b/sound/core/control.c -static bool validate_element_member_dimension(struct snd_ctl_elem_info *info) -{ - unsigned int members; - unsigned int i; - - if (info->dimen.d[0] == 0) - return true; - - members = 1; - for (i = 0; i < array_size(info->dimen.d); ++i) { - if (info->dimen.d[i] == 0) - break; - members *= info->dimen.d[i]; - - /* - * info->count should be validated in advance, to guarantee - * calculation soundness. - */ - if (members > info->count) - return false; - } - - for (++i; i < array_size(info->dimen.d); ++i) { - if (info->dimen.d[i] > 0) - return false; - } - - return members == info->count; -} - - if (!validate_element_member_dimension(info)) - return -einval;
Audio
ff16351e3f302a2913bd17da6ed8f195ab2139fd
takashi sakamoto
sound
core
sound
alsa: ctl: bump protocol version up to v2.1.0
in a development period for v5.6 kernel, some changes are introduced to structures in alsa control interface: - 'tstamp' member is removed from 'struct snd_ctl_elem_value - 'tstamp' flag is removed from a set of access flags for 'struct snd_ctl_elem_info' - 'dimen' member is removed from 'struct snd_ctl_elem_info
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
the already deprecated dimension support in alsa control api is dropped completely now
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
[]
['h']
1
1
1
- 'tstamp' member is removed from 'struct snd_ctl_elem_value - 'tstamp' flag is removed from a set of access flags for 'struct - 'dimen' member is removed from 'struct snd_ctl_elem_info --- diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h -#define sndrv_ctl_version sndrv_protocol_version(2, 0, 7) +#define sndrv_ctl_version sndrv_protocol_version(2, 1, 0)
Audio
bd3eb4e87eb399a9fe15ef1b59db78faf9c20359
takashi sakamoto
include
uapi
sound
alsa: hda - add docking station support for lenovo thinkpad t420s
lenovo thinkpad t420s uses the same codec as t420, so apply the same quirk to enable audio output on a docking station.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add docking station support for lenovo thinkpad t420s
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['hda ']
['c']
1
1
0
--- diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c + snd_pci_quirk(0x17aa, 0x21d2, "lenovo t420s", cxt_pincfg_lenovo_tp410),
Audio
ef7d84caa5928b40b1c93a26dbe5a3f12737c6ab
peter gro e
sound
pci
hda
alsa: hda/realtek - add headset button supported for thinkpad x1
thinkpad want to support headset button control. this patch will enable it.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add headset button supported for thinkpad x1
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['hda ', 'realtek']
['c']
1
9
4
--- diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c - + alc285_fixup_thinkpad_headset_jack, - + [alc285_fixup_thinkpad_headset_jack] = { + .type = hda_fixup_func, + .v.func = alc_fixup_headset_jack, + .chained = true, + .chain_id = alc285_fixup_speaker2_to_dac1 + }, - snd_pci_quirk(0x17aa, 0x2292, "thinkpad x1 yoga 7th", alc285_fixup_speaker2_to_dac1), - snd_pci_quirk(0x17aa, 0x2293, "thinkpad x1 carbon 7th", alc285_fixup_speaker2_to_dac1), + snd_pci_quirk(0x17aa, 0x2292, "thinkpad x1 yoga 7th", alc285_fixup_thinkpad_headset_jack), + snd_pci_quirk(0x17aa, 0x2293, "thinkpad x1 carbon 7th", alc285_fixup_thinkpad_headset_jack),
Audio
76f7dec08fd64e9e3ad0810a1a8a60b0a846d348
kailang yang
sound
pci
hda
alsa: hda/realtek - add headset mic supported
dell desktop platform supported headset mic. add pin verb to enable headset mic. this platform only support fixed type headset for iphone type.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add headset mic supported
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['hda ', 'realtek']
['c']
1
2
0
--- diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c + snd_pci_quirk(0x1028, 0x098d, "dell precision", alc233_fixup_asus_mic_no_presence), + snd_pci_quirk(0x1028, 0x09bf, "dell precision", alc233_fixup_asus_mic_no_presence),
Audio
78def224f59c05d00e815be946ec229719ccf377
kailang yang
sound
pci
hda
alsa: hda/realtek - add headset mic supported for hp cpc
hp alc671 need to support headset mic.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add headset mic supported for hp cpc
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['hda ', 'realtek']
['c']
1
44
0
--- diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c +static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + struct alc_spec *spec = codec->spec; + + static const struct hda_pintbl pincfgs[] = { + { 0x19, 0x02a11040 }, /* use as headset mic, with its own jack detect */ + { 0x1b, 0x0181304f }, + { } + }; + + switch (action) { + case hda_fixup_act_pre_probe: + spec->gen.mixer_nid = 0; + spec->parse_flags |= hda_pincfg_headset_mic; + snd_hda_apply_pincfgs(codec, pincfgs); + break; + case hda_fixup_act_init: + alc_write_coef_idx(codec, 0x19, 0xa054); + break; + } +} + + alc671_fixup_hp_headset_mic2, + [alc671_fixup_hp_headset_mic2] = { + .type = hda_fixup_func, + .v.func = alc671_fixup_hp_headset_mic2, + }, + snd_hda_pin_quirk(0x10ec0671, 0x103c, "hp cpc", alc671_fixup_hp_headset_mic2, + {0x14, 0x01014010}, + {0x17, 0x90170150}, + {0x1b, 0x01813030}, + {0x21, 0x02211020}), + snd_hda_pin_quirk(0x10ec0671, 0x103c, "hp cpc", alc671_fixup_hp_headset_mic2, + {0x14, 0x01014010}, + {0x18, 0x01a19040}, + {0x1b, 0x01813030}, + {0x21, 0x02211020}), + snd_hda_pin_quirk(0x10ec0671, 0x103c, "hp cpc", alc671_fixup_hp_headset_mic2, + {0x14, 0x01014020}, + {0x17, 0x90170110}, + {0x18, 0x01a19050}, + {0x1b, 0x01813040}, + {0x21, 0x02211030}),
Audio
5af29028fd6db9438b5584ab7179710a0a22569d
kailang yang
sound
pci
hda
alsa: hda: add jasperlake pci id and codec vid
add hd audio device pci id and codec vendor_id for the intel jasperlake rev2/a0 silicon.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add jasperlake pci id and codec vid
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['hda ']
['c']
2
3
0
--- diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c + { pci_device(0x8086, 0x4dc8), + .driver_data = azx_driver_skl | azx_dcaps_intel_skylake}, diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c +hda_codec_entry(0x8086281a, "jasperlake hdmi", patch_i915_icl_hdmi),
Audio
78be2228c15dd45865b102b29d72e721f0ace9b1
yong zhi
sound
pci
hda
asoc: amd: use managed buffer allocation
clean up the drivers with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
2
26
62
--- diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c - int status; - status = snd_pcm_lib_malloc_pages(substream, size); - if (status < 0) - return status; - - memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); - if (substream->dma_buffer.area) { - acp_set_sram_bank_state(rtd->acp_mmio, 0, true); - /* save for runtime private data */ - rtd->dma_addr = substream->dma_buffer.addr; - rtd->order = get_order(size); + acp_set_sram_bank_state(rtd->acp_mmio, 0, true); + /* save for runtime private data */ + rtd->dma_addr = substream->dma_buffer.addr; + rtd->order = get_order(size); - /* fill the page table entries in acp sram */ - rtd->size = size; - rtd->num_of_pages = page_align(size) >> page_shift; - rtd->direction = substream->stream; + /* fill the page table entries in acp sram */ + rtd->size = size; + rtd->num_of_pages = page_align(size) >> page_shift; + rtd->direction = substream->stream; - config_acp_dma(rtd->acp_mmio, rtd, adata->asic_type); - status = 0; - } else { - status = -enomem; - } - return status; -} - -static int acp_dma_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + config_acp_dma(rtd->acp_mmio, rtd, adata->asic_type); + return 0; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, - sndrv_dma_type_dev, - parent, - st_min_buffer, - st_max_buffer); + snd_pcm_set_managed_buffer_all(rtd->pcm, + sndrv_dma_type_dev, + parent, + st_min_buffer, + st_max_buffer); - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, - sndrv_dma_type_dev, - parent, - min_buffer, - max_buffer); + snd_pcm_set_managed_buffer_all(rtd->pcm, + sndrv_dma_type_dev, + parent, + min_buffer, + max_buffer); - .hw_free = acp_dma_hw_free, diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c - int status; - status = snd_pcm_lib_malloc_pages(substream, size); - if (status < 0) - return status; - - memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); - if (substream->dma_buffer.area) { - rtd->dma_addr = substream->dma_buffer.addr; - rtd->num_pages = (page_align(size) >> page_shift); - config_acp3x_dma(rtd, substream->stream); - status = 0; - } else { - status = -enomem; - } - return status; + rtd->dma_addr = substream->dma_buffer.addr; + rtd->num_pages = (page_align(size) >> page_shift); + config_acp3x_dma(rtd, substream->stream); + return 0; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, sndrv_dma_type_dev, - parent, min_buffer, max_buffer); + snd_pcm_set_managed_buffer_all(rtd->pcm, sndrv_dma_type_dev, + parent, min_buffer, max_buffer); -static int acp3x_dma_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - - .hw_free = acp3x_dma_hw_free,
Audio
7f4aee8fa79c2d753aa1b2e9ffcad24689317f75
takashi iwai
sound
soc
amd, raven
asoc: amd: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
2
0
2
--- diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
66a7caaf354edd35089dcaabd277b38f036b783b
takashi iwai
sound
soc
amd, raven
asoc: atmel: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c --- a/sound/soc/atmel/atmel-pcm-pdc.c +++ b/sound/soc/atmel/atmel-pcm-pdc.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
7aff4224ff6b603c432de56139b621d68e0307fb
takashi iwai alexandre belloni alexandre belloni bootlin com
sound
soc
atmel
asoc: au1x: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
2
0
2
--- diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
4000fc0b5a7f277ed6f83b1673a833b67a4cfa71
takashi iwai
sound
soc
au1x
asoc: bcm: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/bcm/cygnus-pcm.c b/sound/soc/bcm/cygnus-pcm.c --- a/sound/soc/bcm/cygnus-pcm.c +++ b/sound/soc/bcm/cygnus-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
e7a83dfcb33d36463def773c101051d63d5593ef
takashi iwai
sound
soc
bcm
asoc: dwc: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c --- a/sound/soc/dwc/dwc-pcm.c +++ b/sound/soc/dwc/dwc-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
f6201a314fc780bda83ffc5338c7bc0326749e84
takashi iwai
sound
soc
dwc
asoc: fsl: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
4
0
4
--- diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c - dma->dai.ioctl = snd_soc_pcm_lib_ioctl; diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
6ac44ce9dfd6ba4dfb1d5e571131d132c53f23f1
takashi iwai nicolin chen nicoleotsuka gmail com
sound
soc
fsl
asoc: intel: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
4
0
4
--- diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
aa4708d97e74d161502c9a5bc07532b34e727370
takashi iwai
sound
soc
atom, baytrail, haswell, intel, skylake
asoc: kirkwood: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
13fd6f07f5b1cab528271f908df531a49e0bdcde
takashi iwai
sound
soc
kirkwood
asoc: mediatek: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
4
0
4
--- diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c --- a/sound/soc/mediatek/common/mtk-btcvsd.c +++ b/sound/soc/mediatek/common/mtk-btcvsd.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c --- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
a1b175b0828de15e04b551a8406affcddc552d7d
takashi iwai
sound
soc
common, mediatek, mt6797, mt8183
asoc: meson: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
2
0
6
--- diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c --- a/sound/soc/meson/axg-frddr.c +++ b/sound/soc/meson/axg-frddr.c - .ioctl = snd_soc_pcm_lib_ioctl, - .ioctl = snd_soc_pcm_lib_ioctl, - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/meson/axg-toddr.c b/sound/soc/meson/axg-toddr.c --- a/sound/soc/meson/axg-toddr.c +++ b/sound/soc/meson/axg-toddr.c - .ioctl = snd_soc_pcm_lib_ioctl, - .ioctl = snd_soc_pcm_lib_ioctl, - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
a984e214de0c5d592a50bc6bd04b32a335d48a55
takashi iwai jerome brunet jbrunet baylibre com
sound
soc
meson
asoc: pxa: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
5
0
5
--- diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
92e63b552822b51aac65348b7ae46749590a3c8e
takashi iwai
sound
soc
pxa
asoc: qcom: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
2
0
2
--- diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c - .ioctl = snd_soc_pcm_lib_ioctl, diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
29da4698399eceaac0bfcf1f180e21a51d5d7aed
takashi iwai
sound
soc
qcom, qdsp6
asoc: samsung: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
c4d14046650087f6495ab6855cf1a0090325c48a
takashi iwai
sound
soc
samsung
asoc: generic-dmaengine: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
2
--- diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c - .ioctl = snd_soc_pcm_lib_ioctl, - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
2680c3127c3995c7cbd920c87fbc3411685e7717
takashi iwai
sound
soc
asoc: sof: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c - pd->ioctl = snd_soc_pcm_lib_ioctl;
Audio
620ea8d26b99a5857b12a26f3673ad1fcd8abe9f
takashi iwai
sound
soc
sof
asoc: sprd: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/sprd/sprd-pcm-dma.c b/sound/soc/sprd/sprd-pcm-dma.c --- a/sound/soc/sprd/sprd-pcm-dma.c +++ b/sound/soc/sprd/sprd-pcm-dma.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
01ac8ada97120b582580a7b3059329ddf659d033
takashi iwai baolin wang baolin wang gmail com
sound
soc
sprd
asoc: txx9: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
88b79e98cfc83290c12dd0455743ff84c556628e
takashi iwai
sound
soc
txx9
asoc: xilinx: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
71bfaea3d6d921f4e35e185f7dbd488110e9ce2e
takashi iwai
sound
soc
xilinx
asoc: xtensa: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
6a8228d07ca022b6099b3a2b1432cdfb94bb36c4
takashi iwai
sound
soc
xtensa
asoc: utils: drop superfluous ioctl pcm ops
asoc pcm core deals the empty ioctl field now as default. let's kill the redundant lines.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
0
1
--- diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c - .ioctl = snd_soc_pcm_lib_ioctl,
Audio
93ec6953c1d7b3c5f62d35c76fe6670c6d9b3c8c
takashi iwai
sound
soc
asoc: soc-core: merge soc_set_name_prefix() and soc_set_of_name_prefix()
soc_set_name_prefix() is calling soc_set_of_name_prefix(). we don't need to separate these operation. this patch merges these.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
7
13
--- diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c -static void soc_set_of_name_prefix(struct snd_soc_component *component) -{ - struct device_node *of_node = soc_component_to_node(component); - const char *str; - int ret; - - ret = of_property_read_string(of_node, "sound-name-prefix", &str); - if (!ret) - component->name_prefix = str; -} - - int i; + const char *str; + int ret, i; - soc_set_of_name_prefix(component); + ret = of_property_read_string(of_node, "sound-name-prefix", &str); + if (ret < 0) + return; + + component->name_prefix = str;
Audio
29d9fc7acacbb985daa1b4c662c619dc959a11b0
kuninori morimoto
sound
soc
asoc: soc-core: tidyup for config_dmi
soc-core.c has 2 #ifdef config_dmi, but we can merge these. otoh, soc.h has dmi_longname, but it is needed if config_dmi was defined. in other words, it is not needed if config_dmi was not defined. this patch tidyup these.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['h', 'c']
2
17
17
--- diff --git a/include/sound/soc.h b/include/sound/soc.h --- a/include/sound/soc.h +++ b/include/sound/soc.h +#ifdef config_dmi +#endif /* config_dmi */ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c -#ifdef config_dmi -/* - * if a dmi filed contain strings in this blacklist (e.g. - * "type2 - board manufacturer" or "type1 - tbd by oem"), it will be taken - * as invalid and dropped when setting the card long name from dmi info. - */ -static const char * const dmi_blacklist[] = { - "to be filled by oem", - "tbd by oem", - "default string", - "board manufacturer", - "board vendor name", - "board product name", - null, /* terminator */ -}; -#endif - +/* + * if a dmi filed contain strings in this blacklist (e.g. + * "type2 - board manufacturer" or "type1 - tbd by oem"), it will be taken + * as invalid and dropped when setting the card long name from dmi info. + */ +static const char * const dmi_blacklist[] = { + "to be filled by oem", + "tbd by oem", + "default string", + "board manufacturer", + "board vendor name", + "board product name", + null, /* terminator */ +}; +
Audio
8a6a6a38f86885982891197840e7b8eccad5ef50
kuninori morimoto
include
sound
asoc: soc-core: tidyup for config_debug_fs
soc-core.c has 2 #ifdef config_debug_fs, but we can merge these.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
3
5
--- diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c -#ifdef config_debug_fs -struct dentry *snd_soc_debugfs_root; -export_symbol_gpl(snd_soc_debugfs_root); -#endif - +struct dentry *snd_soc_debugfs_root; +export_symbol_gpl(snd_soc_debugfs_root); +
Audio
a4072cdfa9fe79adcd41320355847e77de22baf0
kuninori morimoto
sound
soc
asoc: au1x: use managed buffer allocation
clean up the drivers with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
2
7
28
--- diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) - goto out; - -static int au1xpsc_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - - snd_pcm_lib_preallocate_pages_for_all(pcm, sndrv_dma_type_dev, + snd_pcm_set_managed_buffer_all(pcm, sndrv_dma_type_dev, - .hw_free = au1xpsc_pcm_hw_free, diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c - int err; - - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; - err = au1000_setup_dma_link(stream, - params_period_bytes(hw_params), - params_periods(hw_params)); - if (err) - snd_pcm_lib_free_pages(substream); - return err; + return au1000_setup_dma_link(stream, + params_period_bytes(hw_params), + params_periods(hw_params)); - return snd_pcm_lib_free_pages(substream); + return 0; - snd_pcm_lib_preallocate_pages_for_all(pcm, sndrv_dma_type_continuous, - null, 65536, (4096 * 1024) - 1); + snd_pcm_set_managed_buffer_all(pcm, sndrv_dma_type_continuous, + null, 65536, (4096 * 1024) - 1);
Audio
fe9912ac58e4fa205faabcccc980eb834cc5f1aa
takashi iwai
sound
soc
au1x
asoc: dwc: use managed buffer allocation
clean up the drivers with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, as well as the superfluous snd_pcm_lib_preallocate_free_for_all() call. as of the result, hw_free and pcm_destruct ops became empty and got removed.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
2
22
--- diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c --- a/sound/soc/dwc/dwc-pcm.c +++ b/sound/soc/dwc/dwc-pcm.c - int ret; - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) - return ret; - else - return 0; -} - -static int dw_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, + snd_pcm_set_managed_buffer_all(rtd->pcm, -static void dw_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - - .hw_free = dw_pcm_hw_free, - .pcm_destruct = dw_pcm_free,
Audio
fcf306efab32975e4f8bdf5e9d3e7c34fe4ce48c
takashi iwai
sound
soc
dwc
asoc: meson: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
4
9
--- diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c --- a/sound/soc/meson/axg-fifo.c +++ b/sound/soc/meson/axg-fifo.c - int ret; - - ret = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(params)); - if (ret < 0) - return ret; - return snd_pcm_lib_free_pages(ss); + return 0; - snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream, - sndrv_dma_type_dev, card->dev, - size, size); + snd_pcm_set_managed_buffer(rtd->pcm->streams[type].substream, + sndrv_dma_type_dev, card->dev, + size, size);
Audio
bace3caa82e1f0b5b667e35b532534b9cbdc4338
takashi iwai jerome brunet jbrunet baylibre com
sound
soc
meson
asoc: dma-sh7760: use managed buffer allocation
clean up the drivers with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
1
13
--- diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) - return ret; - -static int camelot_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, - .hw_free = camelot_hw_free,
Audio
d23a16584b4f4cc7226c75793d1797e5505a193b
takashi iwai
sound
soc
sh
asoc: rcar: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
6
17
--- diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c - snd_pcm_lib_preallocate_pages(substream, - sndrv_dma_type_dev, - dev, - prealloc_buffer, prealloc_buffer_max); + snd_pcm_set_managed_buffer(substream, + sndrv_dma_type_dev, + dev, + prealloc_buffer, prealloc_buffer_max); - int ret; - ret = rsnd_dai_call(hw_params, io, substream, hw_params); - if (ret) - return ret; - - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return rsnd_dai_call(hw_params, io, substream, hw_params); - int ret; - - ret = rsnd_dai_call(hw_free, io, substream); - if (ret) - return ret; - return snd_pcm_lib_free_pages(substream); + return rsnd_dai_call(hw_free, io, substream);
Audio
e494dbcd9be743f41cf842f94ffbc7c56b6b072a
takashi iwai
sound
soc
rcar, sh
asoc: generic-dmaengine-pcm: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the hw_free callback became superfluous and got dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
2
10
--- diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); + return 0; -static int dmaengine_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - - snd_pcm_lib_preallocate_pages(substream, + snd_pcm_set_managed_buffer(substream, - .hw_free = dmaengine_pcm_hw_free, - .hw_free = dmaengine_pcm_hw_free,
Audio
d708c2b36b5d23a7266ca9bfe648533a0f61bdfd
takashi iwai
sound
soc
asoc: stm32: use managed buffer allocation
clean up the drivers with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, as well as the superfluous snd_pcm_lib_preallocate_free_for_all() call. as of the result, hw_free and pcm_destruct ops became empty and got removed.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
2
27
--- diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c - snd_pcm_lib_free_pages(substream); - int ret; - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) - return ret; -static int stm32_adfsdm_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - - return 0; -} - - snd_pcm_lib_preallocate_pages_for_all(pcm, sndrv_dma_type_dev, - priv->dev, size, size); + snd_pcm_set_managed_buffer_all(pcm, sndrv_dma_type_dev, + priv->dev, size, size); -static void stm32_adfsdm_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - - substream = pcm->streams[sndrv_pcm_stream_capture].substream; - if (substream) - snd_pcm_lib_preallocate_free_for_all(pcm); -} - - .hw_free = stm32_adfsdm_pcm_hw_free, - .pcm_destruct = stm32_adfsdm_pcm_free,
Audio
6f7aff352e690bd167d97f8354543855cf6c34b8
takashi iwai
sound
soc
stm
asoc: txx9: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the hw_free callback became superfluous and got dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
1
13
--- diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c - int ret; - - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) - return ret; -static int txx9aclc_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - - snd_pcm_lib_preallocate_pages_for_all(pcm, sndrv_dma_type_dev, + snd_pcm_set_managed_buffer_all(pcm, sndrv_dma_type_dev, - .hw_free = txx9aclc_pcm_hw_free,
Audio
ffe119308cf6f174eb65e2a7c023c85178f5109c
takashi iwai
sound
soc
txx9
asoc: xilinx: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the hw_free callback became superfluous and got dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
1
12
--- diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c - int status; - status = snd_pcm_lib_malloc_pages(substream, size); - if (status < 0) - return status; -static int xlnx_formatter_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, + snd_pcm_set_managed_buffer_all(rtd->pcm, - .hw_free = xlnx_formatter_pcm_hw_free,
Audio
52f0ac153d12beb5af9d8a1ad3013762e919ffa6
takashi iwai
sound
soc
xilinx
asoc: xtensa: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
3
6
--- diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c - int ret; - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - return ret; + return 0; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, sndrv_dma_type_dev, - card->dev, size, size); + snd_pcm_set_managed_buffer_all(rtd->pcm, sndrv_dma_type_dev, + card->dev, size, size);
Audio
bfddcaffd8858973385ec11c6051bb04fa685e6c
takashi iwai
sound
soc
xtensa
asoc: cros_ec_codec: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
4
4
--- diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c --- a/sound/soc/codecs/cros_ec_codec.c +++ b/sound/soc/codecs/cros_ec_codec.c - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; - return snd_pcm_lib_free_pages(substream); + return 0; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, sndrv_dma_type_vmalloc, - null, 0, 0); + snd_pcm_set_managed_buffer_all(rtd->pcm, sndrv_dma_type_vmalloc, + null, 0, 0);
Audio
66b3621b8b6f3e184b5dd34358de41bcd5a73bb5
takashi iwai
sound
soc
codecs
asoc: rt5514-spi: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
4
6
--- diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c - int ret; - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - return ret; + return 0; - return snd_pcm_lib_free_pages(substream); + return 0; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, sndrv_dma_type_vmalloc, - null, 0, 0); + snd_pcm_set_managed_buffer_all(rtd->pcm, sndrv_dma_type_vmalloc, + null, 0, 0);
Audio
cae8055e065644fd1d92d2f0c23a39b6768d168a
takashi iwai
sound
soc
codecs
asoc: rt5677-spi: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
4
6
--- diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c --- a/sound/soc/codecs/rt5677-spi.c +++ b/sound/soc/codecs/rt5677-spi.c - int ret; - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - return ret; + return 0; - return snd_pcm_lib_free_pages(substream); + return 0; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, sndrv_dma_type_vmalloc, - null, 0, 0); + snd_pcm_set_managed_buffer_all(rtd->pcm, sndrv_dma_type_vmalloc, + null, 0, 0);
Audio
9a560089e964c47f9be11cfb174c47aab0db64a3
takashi iwai
sound
soc
codecs
asoc: intel: atom: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the hw_params and hw_free callbacks became superfluous and got dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
1
24
--- diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c -static int sst_media_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - int ret; - - ret = - snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(params)); - if (ret) - return ret; - memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); - return 0; -} - -static int sst_media_hw_free(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - return snd_pcm_lib_free_pages(substream); -} - - .hw_params = sst_media_hw_params, - .hw_free = sst_media_hw_free, - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm,
Audio
02298145559f824b31a4bada8071e59c55b7df88
takashi iwai
sound
soc
atom, intel
asoc: intel: baytrail: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the hw_free callback became superfluous and got dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
2
17
--- diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c - snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - -static int sst_byt_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - dev_dbg(rtd->dev, "pcm: hw_free "); - snd_pcm_lib_free_pages(substream); - - return 0; -} - - snd_pcm_lib_preallocate_pages_for_all(pcm, sndrv_dma_type_dev, - pdata->dma_dev, - size, size); + snd_pcm_set_managed_buffer_all(pcm, sndrv_dma_type_dev, + pdata->dma_dev, size, size); - .hw_free = sst_byt_pcm_hw_free,
Audio
d9c7824aa29d064b205957033463563ac3205fcb
takashi iwai
sound
soc
baytrail, intel
asoc: intel: haswell: use managed buffer allocation
clean up the driver with the new managed buffer allocation api. the hw_free callback became superfluous and got dropped.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
1
16
--- diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) { - dev_err(rtd->dev, "error: could not allocate %d bytes for pcm %d ", - params_buffer_bytes(params), ret); - return ret; - } - -static int hsw_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, - .hw_free = hsw_pcm_hw_free,
Audio
3f93b1ed4ac1e285eafc6da8b354d3577977059a
takashi iwai
sound
soc
haswell, intel
asoc: intel: skylake: use managed buffer allocation
clean up the drivers with the new managed buffer allocation api. the superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. the pcm_construct ops contains only the superfluous call of snd_pcm_lib_preallocate_free_for_all(), so dropped, too.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
adapt the recent pcm api updates to asoc drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
6
20
--- diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c - return snd_pcm_lib_malloc_pages(substream, size); -} - -static int skl_substream_free_pages(struct hdac_bus *bus, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; - struct hdac_bus *bus = dev_get_drvdata(dai->dev); - return skl_substream_free_pages(bus, substream); + return 0; -static void skl_platform_soc_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - - snd_pcm_lib_preallocate_pages_for_all(pcm, - sndrv_dma_type_dev_sg, - &skl->pci->dev, - size, max_prealloc_size); + snd_pcm_set_managed_buffer_all(pcm, + sndrv_dma_type_dev_sg, + &skl->pci->dev, + size, max_prealloc_size); - .pcm_destruct = skl_platform_soc_free,
Audio
51240953f28e0528a975db686d4e9e5938d55829
takashi iwai
sound
soc
intel, skylake
asoc: sof: intel: add codec_mask module parameter
add a module parameter 'codec_mask' to filter out unwanted hda codecs from driver probe. e.g. on most systems, codec_mask=4 will limit to hdmi audio and exclude any external hda codecs.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add codec_mask module parameter
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
1
13
0
--- diff --git a/sound/soc/sof/intel/hda-ctrl.c b/sound/soc/sof/intel/hda-ctrl.c --- a/sound/soc/sof/intel/hda-ctrl.c +++ b/sound/soc/sof/intel/hda-ctrl.c +#include <linux/module.h> +#if is_enabled(config_snd_soc_sof_hda) +static int hda_codec_mask = -1; +module_param_named(codec_mask, hda_codec_mask, int, 0444); +module_parm_desc(codec_mask, "sof hda codec mask for probing"); +#endif + + + if (hda_codec_mask != -1) { + bus->codec_mask &= hda_codec_mask; + dev_dbg(bus->dev, "filtered codec_mask = 0x%lx ", + bus->codec_mask); + }
Audio
4f6250b82cb8f950a1b1bea62843a88bbb208187
kai vehmanen
sound
soc
intel, sof
asoc: add mediatek mt6660 speaker amp driver
the mt6660 is a boosted btl class-d amplifier with v/i sensing. a built-in dc-dc step-up converter is used to provide efficient power for class-d amplifier with multi-level class-g operation. the digital audio interface supports i2s, left-justified, right-justified, tdm and dsp a/b format for audio in with a data out used for chip information like voltage sense and current sense, which are able to be monitored via datao through proper
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add mediatek mt6660 speaker amp driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c', 'kconfig', 'makefile', 'h']
4
598
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_mt6660 if i2c +config snd_soc_mt6660 + tristate "mediatek mt6660 speaker amplifier" + depends on i2c + help + mediatek mt6660 is a smart power amplifier which contain + speaker protection, multi-band drc, equalizer functions. + select n if you don't have mt6660 on board. + select m to build this as module. + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-mt6660-objs := mt6660.o +obj-$(config_snd_soc_mt6660) += snd-soc-mt6660.o diff --git a/sound/soc/codecs/mt6660.c b/sound/soc/codecs/mt6660.c --- /dev/null +++ b/sound/soc/codecs/mt6660.c +// spdx-license-identifier: gpl-2.0 // + +// copyright (c) 2019 mediatek inc. + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/version.h> +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/pm_runtime.h> +#include <linux/delay.h> +#include <linux/debugfs.h> +#include <sound/soc.h> +#include <sound/tlv.h> +#include <sound/pcm_params.h> + +#include "mt6660.h" + +struct reg_size_table { + u32 addr; + u8 size; +}; + +static const struct reg_size_table mt6660_reg_size_table[] = { + { mt6660_reg_hpf1_coef, 4 }, + { mt6660_reg_hpf2_coef, 4 }, + { mt6660_reg_tdm_cfg3, 2 }, + { mt6660_reg_resv17, 2 }, + { mt6660_reg_resv23, 2 }, + { mt6660_reg_sigmax, 2 }, + { mt6660_reg_devid, 2 }, + { mt6660_reg_hclip_ctrl, 2 }, + { mt6660_reg_da_gain, 2 }, +}; + +static int mt6660_get_reg_size(uint32_t addr) +{ + int i; + + for (i = 0; i < array_size(mt6660_reg_size_table); i++) { + if (mt6660_reg_size_table[i].addr == addr) + return mt6660_reg_size_table[i].size; + } + return 1; +} + +static int mt6660_reg_write(void *context, unsigned int reg, unsigned int val) +{ + struct mt6660_chip *chip = context; + int size = mt6660_get_reg_size(reg); + u8 reg_data[4]; + int i, ret; + + for (i = 0; i < size; i++) + reg_data[size - i - 1] = (val >> (8 * i)) & 0xff; + + ret = i2c_smbus_write_i2c_block_data(chip->i2c, reg, size, reg_data); + return ret; +} + +static int mt6660_reg_read(void *context, unsigned int reg, unsigned int *val) +{ + struct mt6660_chip *chip = context; + int size = mt6660_get_reg_size(reg); + int i, ret; + u8 data[4]; + u32 reg_data = 0; + + ret = i2c_smbus_read_i2c_block_data(chip->i2c, reg, size, data); + if (ret < 0) + return ret; + for (i = 0; i < size; i++) { + reg_data <<= 8; + reg_data |= data[i]; + } + *val = reg_data; + return 0; +} + +static const struct regmap_config mt6660_regmap_config = { + .reg_bits = 8, + .val_bits = 32, + .reg_write = mt6660_reg_write, + .reg_read = mt6660_reg_read, +}; + +static int mt6660_codec_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event == snd_soc_dapm_post_pmu) + usleep_range(1000, 1100); + return 0; +} + +static int mt6660_codec_classd_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + int ret; + + switch (event) { + case snd_soc_dapm_pre_pmu: + dev_dbg(component->dev, + "%s: before classd turn on ", __func__); + /* config to adaptive mode */ + ret = snd_soc_component_update_bits(component, + mt6660_reg_bst_ctrl, 0x03, 0x03); + if (ret < 0) { + dev_err(component->dev, "config mode adaptive fail "); + return ret; + } + break; + case snd_soc_dapm_post_pmu: + /* voltage sensing enable */ + ret = snd_soc_component_update_bits(component, + mt6660_reg_resv7, 0x04, 0x04); + if (ret < 0) { + dev_err(component->dev, + "enable voltage sensing fail "); + return ret; + } + dev_dbg(component->dev, "amp on "); + break; + case snd_soc_dapm_pre_pmd: + dev_dbg(component->dev, "amp off "); + /* voltage sensing disable */ + ret = snd_soc_component_update_bits(component, + mt6660_reg_resv7, 0x04, 0x00); + if (ret < 0) { + dev_err(component->dev, + "disable voltage sensing fail "); + return ret; + } + /* pop-noise improvement 1 */ + ret = snd_soc_component_update_bits(component, + mt6660_reg_resv10, 0x10, 0x10); + if (ret < 0) { + dev_err(component->dev, + "pop-noise improvement 1 fail "); + return ret; + } + break; + case snd_soc_dapm_post_pmd: + dev_dbg(component->dev, + "%s: after classd turn off ", __func__); + /* pop-noise improvement 2 */ + ret = snd_soc_component_update_bits(component, + mt6660_reg_resv10, 0x10, 0x00); + if (ret < 0) { + dev_err(component->dev, + "pop-noise improvement 2 fail "); + return ret; + } + /* config to off mode */ + ret = snd_soc_component_update_bits(component, + mt6660_reg_bst_ctrl, 0x03, 0x00); + if (ret < 0) { + dev_err(component->dev, "config mode off fail "); + return ret; + } + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget mt6660_component_dapm_widgets[] = { + snd_soc_dapm_dac_e("dac", null, mt6660_reg_pll_cfg1, + 0, 1, mt6660_codec_dac_event, snd_soc_dapm_post_pmu), + snd_soc_dapm_adc("vi adc", null, snd_soc_nopm, 0, 0), + snd_soc_dapm_pga("pga", snd_soc_nopm, 0, 0, null, 0), + snd_soc_dapm_out_drv_e("classd", mt6660_reg_system_ctrl, 2, 0, + null, 0, mt6660_codec_classd_event, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + snd_soc_dapm_output("outp"), + snd_soc_dapm_output("outn"), +}; + +static const struct snd_soc_dapm_route mt6660_component_dapm_routes[] = { + { "dac", null, "aif_playback" }, + { "pga", null, "dac" }, + { "classd", null, "pga" }, + { "outp", null, "classd" }, + { "outn", null, "classd" }, + { "vi adc", null, "classd" }, + { "aif_capture", null, "vi adc" }, +}; + +static int mt6660_component_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct mt6660_chip *chip = (struct mt6660_chip *) + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = chip->chip_rev & 0x0f; + return 0; +} + +static const declare_tlv_db_scale(vol_ctl_tlv, -1155, 5, 0); + +static const struct snd_kcontrol_new mt6660_component_snd_controls[] = { + soc_single_tlv("digital volume", mt6660_reg_vol_ctrl, 0, 255, + 1, vol_ctl_tlv), + soc_single("hard clip switch", mt6660_reg_hclip_ctrl, 8, 1, 0), + soc_single("clip switch", mt6660_reg_sps_ctrl, 0, 1, 0), + soc_single("boost mode", mt6660_reg_bst_ctrl, 0, 3, 0), + soc_single("dre switch", mt6660_reg_dre_ctrl, 0, 1, 0), + soc_single("dc protect switch", mt6660_reg_dc_protect_ctrl, 3, 1, 0), + soc_single("data output left channel selection", + mt6660_reg_datao_sel, 3, 7, 0), + soc_single("data output right channel selection", + mt6660_reg_datao_sel, 0, 7, 0), + soc_single_ext("t0 sel", mt6660_reg_cali_t0, 0, 7, 0, + snd_soc_get_volsw, null), + soc_single_ext("chip rev", mt6660_reg_devid, 8, 15, 0, + mt6660_component_get_volsw, null), +}; + +static int _mt6660_chip_power_on(struct mt6660_chip *chip, int on_off) +{ + return regmap_write_bits(chip->regmap, mt6660_reg_system_ctrl, + 0x01, on_off ? 0x00 : 0x01); +} + +static int mt6660_component_probe(struct snd_soc_component *component) +{ + struct mt6660_chip *chip = snd_soc_component_get_drvdata(component); + + dev_dbg(component->dev, "%s ", __func__); + snd_soc_component_init_regmap(component, chip->regmap); + + return 0; +} + +static void mt6660_component_remove(struct snd_soc_component *component) +{ + dev_dbg(component->dev, "%s ", __func__); + snd_soc_component_exit_regmap(component); +} + +static const struct snd_soc_component_driver mt6660_component_driver = { + .probe = mt6660_component_probe, + .remove = mt6660_component_remove, + + .controls = mt6660_component_snd_controls, + .num_controls = array_size(mt6660_component_snd_controls), + .dapm_widgets = mt6660_component_dapm_widgets, + .num_dapm_widgets = array_size(mt6660_component_dapm_widgets), + .dapm_routes = mt6660_component_dapm_routes, + .num_dapm_routes = array_size(mt6660_component_dapm_routes), + + .idle_bias_on = false, /* idle_bias_off = true */ +}; + +static int mt6660_component_aif_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) +{ + int word_len = params_physical_width(hw_params); + int aud_bit = params_width(hw_params); + u16 reg_data = 0; + int ret; + + dev_dbg(dai->dev, "%s: ++ ", __func__); + dev_dbg(dai->dev, "format: 0x%08x ", params_format(hw_params)); + dev_dbg(dai->dev, "rate: 0x%08x ", params_rate(hw_params)); + dev_dbg(dai->dev, "word_len: %d, aud_bit: %d ", word_len, aud_bit); + if (word_len > 32 || word_len < 16) { + dev_err(dai->dev, "not supported word length "); + return -enotsupp; + } + switch (aud_bit) { + case 16: + reg_data = 3; + break; + case 18: + reg_data = 2; + break; + case 20: + reg_data = 1; + break; + case 24: + case 32: + reg_data = 0; + break; + default: + return -enotsupp; + } + ret = snd_soc_component_update_bits(dai->component, + mt6660_reg_serial_cfg1, 0xc0, (reg_data << 6)); + if (ret < 0) { + dev_err(dai->dev, "config aud bit fail "); + return ret; + } + ret = snd_soc_component_update_bits(dai->component, + mt6660_reg_tdm_cfg3, 0x3f0, word_len << 4); + if (ret < 0) { + dev_err(dai->dev, "config word len fail "); + return ret; + } + dev_dbg(dai->dev, "%s: -- ", __func__); + return 0; +} + +static const struct snd_soc_dai_ops mt6660_component_aif_ops = { + .hw_params = mt6660_component_aif_hw_params, +}; + +#define stub_rates sndrv_pcm_rate_8000_192000 +#define stub_formats (sndrv_pcm_fmtbit_s16_le | \ + sndrv_pcm_fmtbit_u16_le | \ + sndrv_pcm_fmtbit_s24_le | \ + sndrv_pcm_fmtbit_u24_le | \ + sndrv_pcm_fmtbit_s32_le | \ + sndrv_pcm_fmtbit_u32_le) + +static struct snd_soc_dai_driver mt6660_codec_dai = { + .name = "mt6660-aif", + .playback = { + .stream_name = "aif_playback", + .channels_min = 1, + .channels_max = 2, + .rates = stub_rates, + .formats = stub_formats, + }, + .capture = { + .stream_name = "aif_capture", + .channels_min = 1, + .channels_max = 2, + .rates = stub_rates, + .formats = stub_formats, + }, + /* dai properties */ + .symmetric_rates = 1, + .symmetric_channels = 1, + .symmetric_samplebits = 1, + /* dai operations */ + .ops = &mt6660_component_aif_ops, +}; + +static int _mt6660_chip_id_check(struct mt6660_chip *chip) +{ + int ret; + unsigned int val; + + ret = regmap_read(chip->regmap, mt6660_reg_devid, &val); + if (ret < 0) + return ret; + val &= 0x0ff0; + if (val != 0x00e0 && val != 0x01e0) { + dev_err(chip->dev, "%s id(%x) not match ", __func__, val); + return -enodev; + } + return 0; +} + +static int _mt6660_chip_sw_reset(struct mt6660_chip *chip) +{ + int ret; + + /* turn on main pll first, then trigger reset */ + ret = regmap_write(chip->regmap, mt6660_reg_system_ctrl, 0x00); + if (ret < 0) + return ret; + ret = regmap_write(chip->regmap, mt6660_reg_system_ctrl, 0x80); + if (ret < 0) + return ret; + msleep(30); + return 0; +} + +static int _mt6660_read_chip_revision(struct mt6660_chip *chip) +{ + int ret; + unsigned int val; + + ret = regmap_read(chip->regmap, mt6660_reg_devid, &val); + if (ret < 0) { + dev_err(chip->dev, "get chip revision fail "); + return ret; + } + chip->chip_rev = val&0xff; + dev_info(chip->dev, "%s chip_rev = %x ", __func__, chip->chip_rev); + return 0; +} + +static int mt6660_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct mt6660_chip *chip = null; + int ret; + + dev_dbg(&client->dev, "%s ", __func__); + chip = devm_kzalloc(&client->dev, sizeof(*chip), gfp_kernel); + if (!chip) + return -enomem; + chip->i2c = client; + chip->dev = &client->dev; + mutex_init(&chip->io_lock); + i2c_set_clientdata(client, chip); + + chip->regmap = devm_regmap_init(&client->dev, + null, chip, &mt6660_regmap_config); + if (is_err(chip->regmap)) { + ret = ptr_err(chip->regmap); + dev_err(&client->dev, "failed to initialise regmap: %d ", ret); + return ret; + } + + /* chip reset first */ + ret = _mt6660_chip_sw_reset(chip); + if (ret < 0) { + dev_err(chip->dev, "chip reset fail "); + goto probe_fail; + } + /* chip power on */ + ret = _mt6660_chip_power_on(chip, 1); + if (ret < 0) { + dev_err(chip->dev, "chip power on 2 fail "); + goto probe_fail; + } + /* chip devid check */ + ret = _mt6660_chip_id_check(chip); + if (ret < 0) { + dev_err(chip->dev, "chip id check fail "); + goto probe_fail; + } + /* chip revision get */ + ret = _mt6660_read_chip_revision(chip); + if (ret < 0) { + dev_err(chip->dev, "read chip revision fail "); + goto probe_fail; + } + pm_runtime_set_active(chip->dev); + pm_runtime_enable(chip->dev); + + ret = devm_snd_soc_register_component(chip->dev, + &mt6660_component_driver, + &mt6660_codec_dai, 1); + return ret; +probe_fail: + _mt6660_chip_power_on(chip, 0); + mutex_destroy(&chip->io_lock); + return ret; +} + +static int mt6660_i2c_remove(struct i2c_client *client) +{ + struct mt6660_chip *chip = i2c_get_clientdata(client); + + pm_runtime_disable(chip->dev); + pm_runtime_set_suspended(chip->dev); + mutex_destroy(&chip->io_lock); + return 0; +} + +static int __maybe_unused mt6660_i2c_runtime_suspend(struct device *dev) +{ + struct mt6660_chip *chip = dev_get_drvdata(dev); + + dev_dbg(dev, "enter low power mode "); + return regmap_update_bits(chip->regmap, + mt6660_reg_system_ctrl, 0x01, 0x01); +} + +static int __maybe_unused mt6660_i2c_runtime_resume(struct device *dev) +{ + struct mt6660_chip *chip = dev_get_drvdata(dev); + + dev_dbg(dev, "exit low power mode "); + return regmap_update_bits(chip->regmap, + mt6660_reg_system_ctrl, 0x01, 0x00); +} + +static const struct dev_pm_ops mt6660_dev_pm_ops = { + set_runtime_pm_ops(mt6660_i2c_runtime_suspend, + mt6660_i2c_runtime_resume, null) +}; + +static const struct of_device_id __maybe_unused mt6660_of_id[] = { + { .compatible = "mediatek,mt6660",}, + {}, +}; +module_device_table(of, mt6660_of_id); + +static const struct i2c_device_id mt6660_i2c_id[] = { + {"mt6660", 0 }, + {}, +}; +module_device_table(i2c, mt6660_i2c_id); + +static struct i2c_driver mt6660_i2c_driver = { + .driver = { + .name = "mt6660", + .of_match_table = of_match_ptr(mt6660_of_id), + .pm = &mt6660_dev_pm_ops, + }, + .probe = mt6660_i2c_probe, + .remove = mt6660_i2c_remove, + .id_table = mt6660_i2c_id, +}; +module_i2c_driver(mt6660_i2c_driver); + +module_author("jeff chang <jeff_chang@richtek.com>"); +module_description("mt6660 spkamp driver"); +module_license("gpl"); +module_version("1.0.7_g"); diff --git a/sound/soc/codecs/mt6660.h b/sound/soc/codecs/mt6660.h --- /dev/null +++ b/sound/soc/codecs/mt6660.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * copyright (c) 2019 mediatek inc. + */ + +#ifndef __snd_soc_mt6660_h +#define __snd_soc_mt6660_h + +#include <linux/mutex.h> +#include <linux/regmap.h> + +#pragma pack(push, 1) +struct mt6660_platform_data { + u8 init_setting_num; + u32 *init_setting_addr; + u32 *init_setting_mask; + u32 *init_setting_val; +}; + +struct mt6660_chip { + struct i2c_client *i2c; + struct device *dev; + struct platform_device *param_dev; + struct mt6660_platform_data plat_data; + struct mutex io_lock; + struct regmap *regmap; + u16 chip_rev; +}; +#pragma pack(pop) + +#define mt6660_reg_devid (0x00) +#define mt6660_reg_system_ctrl (0x03) +#define mt6660_reg_irq_status1 (0x05) +#define mt6660_reg_adda_clock (0x07) +#define mt6660_reg_serial_cfg1 (0x10) +#define mt6660_reg_datao_sel (0x12) +#define mt6660_reg_tdm_cfg3 (0x15) +#define mt6660_reg_hpf_ctrl (0x18) +#define mt6660_reg_hpf1_coef (0x1a) +#define mt6660_reg_hpf2_coef (0x1b) +#define mt6660_reg_path_bypass (0x1e) +#define mt6660_reg_wdt_ctrl (0x20) +#define mt6660_reg_hclip_ctrl (0x24) +#define mt6660_reg_vol_ctrl (0x29) +#define mt6660_reg_sps_ctrl (0x30) +#define mt6660_reg_sigmax (0x33) +#define mt6660_reg_cali_t0 (0x3f) +#define mt6660_reg_bst_ctrl (0x40) +#define mt6660_reg_protection_cfg (0x46) +#define mt6660_reg_da_gain (0x4c) +#define mt6660_reg_audio_in2_sel (0x50) +#define mt6660_reg_sig_gain (0x51) +#define mt6660_reg_pll_cfg1 (0x60) +#define mt6660_reg_dre_ctrl (0x68) +#define mt6660_reg_dre_thdmode (0x69) +#define mt6660_reg_dre_corase (0x6b) +#define mt6660_reg_pwm_ctrl (0x70) +#define mt6660_reg_dc_protect_ctrl (0x74) +#define mt6660_reg_adc_usb_mode (0x7c) +#define mt6660_reg_internal_cfg (0x88) +#define mt6660_reg_resv0 (0x98) +#define mt6660_reg_resv1 (0x99) +#define mt6660_reg_resv2 (0x9a) +#define mt6660_reg_resv3 (0x9b) +#define mt6660_reg_resv6 (0xa2) +#define mt6660_reg_resv7 (0xa3) +#define mt6660_reg_resv10 (0xb0) +#define mt6660_reg_resv11 (0xb1) +#define mt6660_reg_resv16 (0xb6) +#define mt6660_reg_resv17 (0xb7) +#define mt6660_reg_resv19 (0xb9) +#define mt6660_reg_resv21 (0xbb) +#define mt6660_reg_resv23 (0xbd) +#define mt6660_reg_resv31 (0xd3) +#define mt6660_reg_resv40 (0xe0) + +#endif /* __snd_soc_mt6660_h */
Audio
f289e55c6eeb4391101a42334e8c69bf8c9fe987
jeff chang
sound
soc
codecs
asoc: intel: add machine driver for da7219_max98373
this patch adds sof_da7219_max98373 machine driver.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add machine driver for da7219_max98373
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'intel']
['c', 'kconfig', 'makefile']
4
399
0
--- diff --git a/sound/soc/intel/boards/kconfig b/sound/soc/intel/boards/kconfig --- a/sound/soc/intel/boards/kconfig +++ b/sound/soc/intel/boards/kconfig +if snd_soc_sof_jasperlake + +config snd_soc_intel_sof_da7219_max98373_mach + tristate "sof with da7219 and max98373 in i2s mode" + depends on i2c && acpi + depends on mfd_intel_lpss || compile_test + select snd_soc_da7219 + select snd_soc_max98373 + select snd_soc_dmic + select snd_hda_codec_hdmi if snd_soc_sof_hda_audio_codec + help + this adds support for asoc machine driver for sof platforms + with da7219 + max98373 i2s audio codec. + say y if you have such a device. + if unsure select "n". + +endif ## snd_soc_sof_jasperlake + diff --git a/sound/soc/intel/boards/makefile b/sound/soc/intel/boards/makefile --- a/sound/soc/intel/boards/makefile +++ b/sound/soc/intel/boards/makefile +snd-soc-sof_da7219_max98373-objs := sof_da7219_max98373.o hda_dsp_common.o +obj-$(config_snd_soc_intel_sof_da7219_max98373_mach) += snd-soc-sof_da7219_max98373.o + diff --git a/sound/soc/intel/boards/sof_da7219_max98373.c b/sound/soc/intel/boards/sof_da7219_max98373.c --- /dev/null +++ b/sound/soc/intel/boards/sof_da7219_max98373.c +// spdx-license-identifier: gpl-2.0 +// copyright(c) 2019 intel corporation. + +/* + * intel sof machine driver for da7219 + max98373 codec + */ + +#include <linux/input.h> +#include <linux/module.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <linux/platform_device.h> +#include <sound/soc.h> +#include <sound/soc-acpi.h> +#include "../../codecs/da7219.h" +#include "../../codecs/da7219-aad.h" +#include "hda_dsp_common.h" + +#define dialog_codec_dai "da7219-hifi" +#define max98373_codec_dai "max98373-aif1" +#define maxim_dev0_name "i2c-mx98373:00" +#define maxim_dev1_name "i2c-mx98373:01" + +struct hdmi_pcm { + struct list_head head; + struct snd_soc_dai *codec_dai; + int device; +}; + +struct card_private { + struct snd_soc_jack headset; + struct list_head hdmi_pcm_list; + struct snd_soc_jack hdmi[3]; +}; + +static int platform_clock_control(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_soc_card *card = dapm->card; + struct snd_soc_dai *codec_dai; + int ret = 0; + + codec_dai = snd_soc_card_get_codec_dai(card, dialog_codec_dai); + if (!codec_dai) { + dev_err(card->dev, "codec dai not found; unable to set/unset codec pll "); + return -eio; + } + + if (snd_soc_dapm_event_off(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, da7219_sysclk_mclk, + 0, 0); + if (ret) + dev_err(card->dev, "failed to stop pll: %d ", ret); + } else if (snd_soc_dapm_event_on(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, da7219_sysclk_pll_srm, + 0, da7219_pll_freq_out_98304); + if (ret) + dev_err(card->dev, "failed to start pll: %d ", ret); + } + + return ret; +} + +static const struct snd_kcontrol_new controls[] = { + soc_dapm_pin_switch("headphone jack"), + soc_dapm_pin_switch("headset mic"), + soc_dapm_pin_switch("left spk"), + soc_dapm_pin_switch("right spk"), +}; + +static const struct snd_soc_dapm_widget widgets[] = { + snd_soc_dapm_hp("headphone jack", null), + snd_soc_dapm_mic("headset mic", null), + snd_soc_dapm_spk("left spk", null), + snd_soc_dapm_spk("right spk", null), + snd_soc_dapm_supply("platform clock", snd_soc_nopm, 0, 0, + platform_clock_control, snd_soc_dapm_post_pmd | + snd_soc_dapm_pre_pmu), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + { "headphone jack", null, "hpl" }, + { "headphone jack", null, "hpr" }, + + { "left spk", null, "left be_out" }, + { "right spk", null, "right be_out" }, + + { "mic", null, "headset mic" }, + + { "headphone jack", null, "platform clock" }, + { "headset mic", null, "platform clock" }, +}; + +static struct snd_soc_jack headset; + +static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *component = rtd->codec_dai->component; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_jack *jack; + int ret; + + /* configure sysclk for codec */ + ret = snd_soc_dai_set_sysclk(codec_dai, da7219_clksrc_mclk, 24000000, + snd_soc_clock_in); + if (ret) { + dev_err(rtd->dev, "can't set codec sysclk configuration "); + return ret; + } + + /* + * headset buttons map to the google reference headset. + * these can be configured by userspace. + */ + ret = snd_soc_card_jack_new(rtd->card, "headset jack", + snd_jack_headset | snd_jack_btn_0 | + snd_jack_btn_1 | snd_jack_btn_2 | + snd_jack_btn_3 | snd_jack_lineout, + &headset, null, 0); + if (ret) { + dev_err(rtd->dev, "headset jack creation failed: %d ", ret); + return ret; + } + + jack = &headset; + snd_jack_set_key(jack->jack, snd_jack_btn_0, key_playpause); + snd_jack_set_key(jack->jack, snd_jack_btn_1, key_volumeup); + snd_jack_set_key(jack->jack, snd_jack_btn_2, key_volumedown); + snd_jack_set_key(jack->jack, snd_jack_btn_3, key_voicecommand); + da7219_aad_jack_det(component, jack); + + return ret; +} + +static int ssp1_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *runtime = substream->private_data; + int ret, j; + + for (j = 0; j < runtime->num_codecs; j++) { + struct snd_soc_dai *codec_dai = runtime->codec_dais[j]; + + if (!strcmp(codec_dai->component->name, maxim_dev0_name)) { + /* vmon_slot_no = 0 imon_slot_no = 1 for tx slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 3, 4, 16); + if (ret < 0) { + dev_err(runtime->dev, "dev0 tdm slot err:%d ", ret); + return ret; + } + } + if (!strcmp(codec_dai->component->name, maxim_dev1_name)) { + /* vmon_slot_no = 2 imon_slot_no = 3 for tx slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xc, 3, 4, 16); + if (ret < 0) { + dev_err(runtime->dev, "dev1 tdm slot err:%d ", ret); + return ret; + } + } + } + + return 0; +} + +static struct snd_soc_ops ssp1_ops = { + .hw_params = ssp1_hw_params, +}; + +static struct snd_soc_codec_conf max98373_codec_conf[] = { + { + .dlc = comp_codec_conf(maxim_dev0_name), + .name_prefix = "right", + }, + { + .dlc = comp_codec_conf(maxim_dev1_name), + .name_prefix = "left", + }, +}; + +static int hdmi_init(struct snd_soc_pcm_runtime *rtd) +{ + struct card_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + struct hdmi_pcm *pcm; + + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), gfp_kernel); + if (!pcm) + return -enomem; + + pcm->device = dai->id; + pcm->codec_dai = dai; + + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + + return 0; +} + +static int card_late_probe(struct snd_soc_card *card) +{ + struct card_private *ctx = snd_soc_card_get_drvdata(card); + struct snd_soc_acpi_mach *mach = (card->dev)->platform_data; + struct hdmi_pcm *pcm; + + if (mach->mach_params.common_hdmi_codec_drv) { + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm, + head); + return hda_dsp_hdmi_build_controls(card, + pcm->codec_dai->component); + } + + return -einval; +} + +snd_soc_dailink_def(ssp0_pin, + dailink_comp_array(comp_cpu("ssp0 pin"))); +snd_soc_dailink_def(ssp0_codec, + dailink_comp_array(comp_codec("i2c-dlgs7219:00", dialog_codec_dai))); + +snd_soc_dailink_def(ssp1_pin, + dailink_comp_array(comp_cpu("ssp1 pin"))); +snd_soc_dailink_def(ssp1_amps, + dailink_comp_array( + /* left */ comp_codec(maxim_dev0_name, max98373_codec_dai), + /* right */ comp_codec(maxim_dev1_name, max98373_codec_dai))); + +snd_soc_dailink_def(dmic_pin, + dailink_comp_array(comp_cpu("dmic01 pin"))); +snd_soc_dailink_def(dmic_codec, + dailink_comp_array(comp_codec("dmic-codec", "dmic-hifi"))); + +snd_soc_dailink_def(idisp1_pin, + dailink_comp_array(comp_cpu("idisp1 pin"))); +snd_soc_dailink_def(idisp1_codec, + dailink_comp_array(comp_codec("ehdaudio0d2", "intel-hdmi-hifi1"))); + +snd_soc_dailink_def(idisp2_pin, + dailink_comp_array(comp_cpu("idisp2 pin"))); +snd_soc_dailink_def(idisp2_codec, + dailink_comp_array(comp_codec("ehdaudio0d2", "intel-hdmi-hifi2"))); + +snd_soc_dailink_def(idisp3_pin, + dailink_comp_array(comp_cpu("idisp3 pin"))); +snd_soc_dailink_def(idisp3_codec, + dailink_comp_array(comp_codec("ehdaudio0d2", "intel-hdmi-hifi3"))); + +snd_soc_dailink_def(platform, /* subject to be overridden during probe */ + dailink_comp_array(comp_platform("0000:00:1f.3"))); + +static struct snd_soc_dai_link dais[] = { + /* back end dai links */ + { + .name = "ssp1-codec", + .id = 0, + .ignore_pmdown_time = 1, + .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, /* iv feedback */ + .ops = &ssp1_ops, + snd_soc_dailink_reg(ssp1_pin, ssp1_amps, platform), + }, + { + .name = "ssp0-codec", + .id = 1, + .no_pcm = 1, + .init = da7219_codec_init, + .ignore_pmdown_time = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + snd_soc_dailink_reg(ssp0_pin, ssp0_codec, platform), + }, + { + .name = "dmic01", + .id = 2, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + snd_soc_dailink_reg(dmic_pin, dmic_codec, platform), + }, + { + .name = "idisp1", + .id = 3, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + snd_soc_dailink_reg(idisp1_pin, idisp1_codec, platform), + }, + { + .name = "idisp2", + .id = 4, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + snd_soc_dailink_reg(idisp2_pin, idisp2_codec, platform), + }, + { + .name = "idisp3", + .id = 5, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + snd_soc_dailink_reg(idisp3_pin, idisp3_codec, platform), + }, +}; + +static struct snd_soc_card card_da7219_m98373 = { + .name = "da7219max", + .owner = this_module, + .dai_link = dais, + .num_links = array_size(dais), + .controls = controls, + .num_controls = array_size(controls), + .dapm_widgets = widgets, + .num_dapm_widgets = array_size(widgets), + .dapm_routes = audio_map, + .num_dapm_routes = array_size(audio_map), + .codec_conf = max98373_codec_conf, + .num_configs = array_size(max98373_codec_conf), + .fully_routed = true, + .late_probe = card_late_probe, +}; + +static int audio_probe(struct platform_device *pdev) +{ + static struct snd_soc_card *card; + struct snd_soc_acpi_mach *mach; + struct card_private *ctx; + int ret; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), gfp_atomic); + if (!ctx) + return -enomem; + + init_list_head(&ctx->hdmi_pcm_list); + card = (struct snd_soc_card *)pdev->id_entry->driver_data; + card->dev = &pdev->dev; + + mach = (&pdev->dev)->platform_data; + ret = snd_soc_fixup_dai_links_platform_name(card, + mach->mach_params.platform); + if (ret) + return ret; + + snd_soc_card_set_drvdata(card, ctx); + + return devm_snd_soc_register_card(&pdev->dev, card); +} + +static const struct platform_device_id board_ids[] = { + { + .name = "sof_da7219_max98373", + .driver_data = (kernel_ulong_t)&card_da7219_m98373, + }, + { } +}; + +static struct platform_driver audio = { + .probe = audio_probe, + .driver = { + .name = "sof_da7219_max98373", + .pm = &snd_soc_pm_ops, + }, + .id_table = board_ids, +}; +module_platform_driver(audio) + +/* module information */ +module_description("asoc intel(r) sof machine driver"); +module_author("yong zhi <yong.zhi@intel.com>"); +module_license("gpl v2"); +module_alias("platform:sof_da7219_max98373"); diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c + { + .id = "dlgs7219", + .drv_name = "sof_da7219_max98373", + .machine_quirk = snd_soc_acpi_codec_list, + .sof_fw_filename = "sof-jsl.ri", + .sof_tplg_filename = "sof-jsl-da7219.tplg", + },
Audio
35dc19ad86fdf6a2af30c10c281e5fe10d45c041
yong zhi
sound
soc
boards, common, intel
asoc: intel: common: add match tables for cnl/cfl/cml w/ soundwire
the two configurations are with the realtek 3-in-1 board requiring all 4 links to be enabled, or basic configuration with the on-board rt700 using link1.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add match tables for cnl/cfl/cml w/ soundwire
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'intel', 'common']
['c']
3
99
0
--- diff --git a/sound/soc/intel/common/soc-acpi-intel-cfl-match.c b/sound/soc/intel/common/soc-acpi-intel-cfl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-cfl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cfl-match.c +struct snd_soc_acpi_mach snd_soc_acpi_intel_cfl_sdw_machines[] = { + {} +}; +export_symbol_gpl(snd_soc_acpi_intel_cfl_sdw_machines); + diff --git a/sound/soc/intel/common/soc-acpi-intel-cml-match.c b/sound/soc/intel/common/soc-acpi-intel-cml-match.c --- a/sound/soc/intel/common/soc-acpi-intel-cml-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cml-match.c +static const u64 rt711_0_adr[] = { + 0x000010025d071100 +}; + +static const u64 rt1308_1_adr[] = { + 0x000110025d130800 +}; + +static const u64 rt1308_2_adr[] = { + 0x000210025d130800 +}; + +static const u64 rt715_3_adr[] = { + 0x000310025d071500 +}; + +static const struct snd_soc_acpi_link_adr cml_3_in_1_default[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = bit(2), + .num_adr = array_size(rt1308_2_adr), + .adr = rt1308_2_adr, + }, + { + .mask = bit(3), + .num_adr = array_size(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr cml_3_in_1_mono_amp[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = bit(3), + .num_adr = array_size(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_sdw_machines[] = { + { + .link_mask = 0xf, /* 4 active links required */ + .links = cml_3_in_1_default, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-cml.ri", + .sof_tplg_filename = "sof-cml-rt711-rt1308-rt715.tplg", + }, + { + /* + * link_mask should be 0xb, but all links are enabled by bios. + * this entry will be selected if there is no rt1308 exposed + * on link2 since it will fail to match the above entry. + */ + .link_mask = 0xf, + .links = cml_3_in_1_mono_amp, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-cml.ri", + .sof_tplg_filename = "sof-cml-rt711-rt1308-mono-rt715.tplg", + }, + { + .link_mask = 0x2, /* rt700 connected on link1 */ + .drv_name = "sdw_rt700", + .sof_fw_filename = "sof-cml.ri", + .sof_tplg_filename = "sof-cml-rt700.tplg", + }, + {} +}; +export_symbol_gpl(snd_soc_acpi_intel_cml_sdw_machines); + diff --git a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c +struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_sdw_machines[] = { + {}, +}; +export_symbol_gpl(snd_soc_acpi_intel_cnl_sdw_machines); +
Audio
db0b9efb989f01aa7145d30bcdbfb6b07e238875
rander wang
sound
soc
common, intel
asoc: intel: common: add match tables for icl w/ soundwire
the two configurations are with the realtek 3-in-1 board requiring all 4 links to be enabled, or basic configuration with the on-board rt700 using link0.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add match tables for icl w/ soundwire
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'intel', 'common']
['c']
1
98
0
--- diff --git a/sound/soc/intel/common/soc-acpi-intel-icl-match.c b/sound/soc/intel/common/soc-acpi-intel-icl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-icl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-icl-match.c +static const u64 rt700_0_adr[] = { + 0x000010025d070000 +}; + +static const struct snd_soc_acpi_link_adr icl_rvp[] = { + { + .mask = bit(0), + .num_adr = array_size(rt700_0_adr), + .adr = rt700_0_adr, + }, + {} +}; + +static const u64 rt711_0_adr[] = { + 0x000010025d071100 +}; + +static const u64 rt1308_1_adr[] = { + 0x000110025d130800 +}; + +static const u64 rt1308_2_adr[] = { + 0x000210025d130800 +}; + +static const u64 rt715_3_adr[] = { + 0x000310025d715000 +}; + +static const struct snd_soc_acpi_link_adr icl_3_in_1_default[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = bit(2), + .num_adr = array_size(rt1308_2_adr), + .adr = rt1308_2_adr, + }, + { + .mask = bit(3), + .num_adr = array_size(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr icl_3_in_1_mono_amp[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = bit(3), + .num_adr = array_size(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +struct snd_soc_acpi_mach snd_soc_acpi_intel_icl_sdw_machines[] = { + { + .link_mask = 0xf, /* 4 active links required */ + .links = icl_3_in_1_default, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-icl.ri", + .sof_tplg_filename = "sof-icl-rt711-rt1308-rt715.tplg", + }, + { + .link_mask = 0xb, /* 3 active links required */ + .links = icl_3_in_1_mono_amp, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-icl.ri", + .sof_tplg_filename = "sof-icl-rt711-rt1308-rt715-mono.tplg", + }, + { + .link_mask = 0x1, /* rt700 connected on link0 */ + .links = icl_rvp, + .drv_name = "sdw_rt700", + .sof_fw_filename = "sof-icl.ri", + .sof_tplg_filename = "sof-icl-rt700.tplg", + }, + {}, +}; +export_symbol_gpl(snd_soc_acpi_intel_icl_sdw_machines); +
Audio
4313dd3efe5751238f85dd7069bee3a8bbcdbe2f
bard liao
sound
soc
common, intel
asoc: intel: common: add match tables for tgl w/ soundwire
rt711 is in soundwire mode on link0. rt1308 is either on ssp2 or on soundwire link1 (depending on hardware reworks).
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add match tables for tgl w/ soundwire
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'intel', 'common']
['c']
1
49
2
--- diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +static const u64 rt711_0_adr[] = { + 0x000010025d071100 +}; + +static const u64 rt1308_1_adr[] = { + 0x000120025d130800, + 0x000122025d130800 +}; + +static const struct snd_soc_acpi_link_adr tgl_i2s_rt1308[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_0_adr), + .adr = rt711_0_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr tgl_rvp[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + {} +}; + - .drv_name = "tgl_rt1308", + .drv_name = "rt711_rt1308", + .link_mask = 0x1, /* rt711 on soundwire link0 */ + .links = tgl_i2s_rt1308, - .sof_tplg_filename = "sof-tgl-rt1308.tplg", + .sof_tplg_filename = "sof-tgl-rt711-rt1308.tplg", +/* this table is used when there is no i2s codec present */ +struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[] = { + { + .link_mask = 0x3, /* rt711 on link 0 and 2 rt1308s on link 1 */ + .links = tgl_rvp, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-tgl.ri", + .sof_tplg_filename = "sof-tgl-rt711-rt1308.tplg", + }, + {}, +}; +export_symbol_gpl(snd_soc_acpi_intel_tgl_sdw_machines); +
Audio
d985d208bf8f079979f284864a6d08900597ee04
pierre louis bossart
sound
soc
common, intel
asoc: sof: add asynchronous sample rate converter topology support
this patch adds into sof topology the handling of asrc dapm type, adds the tokens to configure the asrc, and implement component ipc into the driver.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add asynchronous sample rate converter topology support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof']
['h', 'c']
4
112
1
--- diff --git a/include/sound/sof/topology.h b/include/sound/sof/topology.h --- a/include/sound/sof/topology.h +++ b/include/sound/sof/topology.h + sof_comp_asrc, /**< asynchronous sample rate converter */ +/* generic asrc component */ +struct sof_ipc_comp_asrc { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + /* either source or sink rate must be non zero */ + uint32_t source_rate; /**< define fixed source rate or */ + /**< use 0 to indicate need to get */ + /**< the rate from stream */ + uint32_t sink_rate; /**< define fixed sink rate or */ + /**< use 0 to indicate need to get */ + /**< the rate from stream */ + uint32_t asynchronous_mode; /**< synchronous 0, asynchronous 1 */ + /**< when 1 the asrc tracks and */ + /**< compensates for drift. */ + uint32_t operation_mode; /**< push 0, pull 1, in push mode the */ + /**< asrc consumes a defined number */ + /**< of frames at input, with varying */ + /**< number of frames at output. */ + /**< in pull mode the asrc outputs */ + /**< a defined number of frames while */ + /**< number of input frames varies. */ + + /* reserved for future use */ + uint32_t reserved[4]; +} __attribute__((packed)); + diff --git a/include/uapi/sound/sof/abi.h b/include/uapi/sound/sof/abi.h --- a/include/uapi/sound/sof/abi.h +++ b/include/uapi/sound/sof/abi.h -#define sof_abi_minor 11 +#define sof_abi_minor 12 diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h --- a/include/uapi/sound/sof/tokens.h +++ b/include/uapi/sound/sof/tokens.h +/* asrc */ +#define sof_tkn_asrc_rate_in 320 +#define sof_tkn_asrc_rate_out 321 +#define sof_tkn_asrc_asynchronous_mode 322 +#define sof_tkn_asrc_operation_mode 323 + diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c +/* asrc */ +static const struct sof_topology_token asrc_tokens[] = { + {sof_tkn_asrc_rate_in, snd_soc_tplg_tuple_type_word, get_token_u32, + offsetof(struct sof_ipc_comp_asrc, source_rate), 0}, + {sof_tkn_asrc_rate_out, snd_soc_tplg_tuple_type_word, get_token_u32, + offsetof(struct sof_ipc_comp_asrc, sink_rate), 0}, + {sof_tkn_asrc_asynchronous_mode, snd_soc_tplg_tuple_type_word, + get_token_u32, + offsetof(struct sof_ipc_comp_asrc, asynchronous_mode), 0}, + {sof_tkn_asrc_operation_mode, snd_soc_tplg_tuple_type_word, + get_token_u32, + offsetof(struct sof_ipc_comp_asrc, operation_mode), 0}, +}; + +/* + * asrc topology + */ + +static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index, + struct snd_sof_widget *swidget, + struct snd_soc_tplg_dapm_widget *tw, + struct sof_ipc_comp_reply *r) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_soc_tplg_private *private = &tw->priv; + struct sof_ipc_comp_asrc *asrc; + int ret; + + asrc = kzalloc(sizeof(*asrc), gfp_kernel); + if (!asrc) + return -enomem; + + /* configure asrc ipc message */ + asrc->comp.hdr.size = sizeof(*asrc); + asrc->comp.hdr.cmd = sof_ipc_glb_tplg_msg | sof_ipc_tplg_comp_new; + asrc->comp.id = swidget->comp_id; + asrc->comp.type = sof_comp_asrc; + asrc->comp.pipeline_id = index; + asrc->config.hdr.size = sizeof(asrc->config); + + ret = sof_parse_tokens(scomp, asrc, asrc_tokens, + array_size(asrc_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "error: parse asrc tokens failed %d ", + private->size); + goto err; + } + + ret = sof_parse_tokens(scomp, &asrc->config, comp_tokens, + array_size(comp_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "error: parse asrc.cfg tokens failed %d ", + le32_to_cpu(private->size)); + goto err; + } + + dev_dbg(scomp->dev, "asrc %s: source rate %d sink rate %d " + "asynch %d operation %d ", + swidget->widget->name, asrc->source_rate, asrc->sink_rate, + asrc->asynchronous_mode, asrc->operation_mode); + sof_dbg_comp_config(scomp, &asrc->config); + + swidget->private = asrc; + + ret = sof_ipc_tx_message(sdev->ipc, asrc->comp.hdr.cmd, asrc, + sizeof(*asrc), r, sizeof(*r)); + if (ret >= 0) + return ret; +err: + kfree(asrc); + return ret; +} + + case snd_soc_dapm_asrc: + ret = sof_widget_load_asrc(scomp, index, swidget, tw, &reply); + break;
Audio
433363e779ecb772c2e9ffea5c9f266115c24441
seppo ingalsuo
include
uapi
sof, sound
asoc: sof: intel: add pci id for jasperlake
mirror id added for legacy hdaudio.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add pci id for jasperlake
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
1
2
0
--- diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c + { pci_device(0x8086, 0x4dc8), + .driver_data = (unsigned long)&jsl_desc},
Audio
6ba7fc99680b2250deba1a23f34d31fd25125d61
yong zhi
sound
soc
sof
asoc: sof: intel: add module namespace for legacy ipc
the legacy ipc routines are only used by broadwell and baytrail modules, import them as needed and make sure other modules cannot load them.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
3
6
4
--- diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c +module_import_ns(snd_soc_sof_intel_hifi_ep_ipc); diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c +module_import_ns(snd_soc_sof_intel_hifi_ep_ipc); diff --git a/sound/soc/sof/intel/intel-ipc.c b/sound/soc/sof/intel/intel-ipc.c --- a/sound/soc/sof/intel/intel-ipc.c +++ b/sound/soc/sof/intel/intel-ipc.c -export_symbol(intel_ipc_msg_data); +export_symbol_ns(intel_ipc_msg_data, snd_soc_sof_intel_hifi_ep_ipc); -export_symbol(intel_ipc_pcm_params); +export_symbol_ns(intel_ipc_pcm_params, snd_soc_sof_intel_hifi_ep_ipc); -export_symbol(intel_pcm_open); +export_symbol_ns(intel_pcm_open, snd_soc_sof_intel_hifi_ep_ipc); -export_symbol(intel_pcm_close); +export_symbol_ns(intel_pcm_close, snd_soc_sof_intel_hifi_ep_ipc);
Audio
f4483a0fda1df3e5b4f25de647b8777d2481f08c
pierre louis bossart
sound
soc
intel, sof
asoc: sof: intel: add namespaces for baytrail and merrifield
define separate namespaces and include them in acpi and pci top-level modules.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
3
8
6
--- diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c -export_symbol(sof_tng_ops); +export_symbol_ns(sof_tng_ops, snd_soc_sof_merrifield); -export_symbol(tng_chip_info); +export_symbol_ns(tng_chip_info, snd_soc_sof_merrifield); -export_symbol(sof_byt_ops); +export_symbol_ns(sof_byt_ops, snd_soc_sof_baytrail); -export_symbol(byt_chip_info); +export_symbol_ns(byt_chip_info, snd_soc_sof_baytrail); -export_symbol(sof_cht_ops); +export_symbol_ns(sof_cht_ops, snd_soc_sof_baytrail); -export_symbol(cht_chip_info); +export_symbol_ns(cht_chip_info, snd_soc_sof_baytrail); diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c +module_import_ns(snd_soc_sof_baytrail); diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c +module_import_ns(snd_soc_sof_merrifield);
Audio
e42b19450866fbd447e459d8935c208e3888705a
pierre louis bossart
sound
soc
intel, sof
asoc: sof: intel: add namespace for broadwell
define namespace and include it in acpi top-level module.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
2
3
2
--- diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c -export_symbol(sof_bdw_ops); +export_symbol_ns(sof_bdw_ops, snd_soc_sof_broadwell); -export_symbol(bdw_chip_info); +export_symbol_ns(bdw_chip_info, snd_soc_sof_broadwell); diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c +module_import_ns(snd_soc_sof_broadwell);
Audio
8caa99bb5d8007fdd206ed6ba2fe4f881b1552c7
pierre louis bossart
sound
soc
intel, sof
asoc: sof: remove references to haswell
there are no known commercial devices using haswell, and there is no support for haswell in sof so remove remaining definitions and structures.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['h', 'kconfig', 'c']
3
3
25
--- diff --git a/sound/soc/sof/kconfig b/sound/soc/sof/kconfig --- a/sound/soc/sof/kconfig +++ b/sound/soc/sof/kconfig - to enable intel haswell/broadwell/baytrail/cherrytrail devices + to enable intel broadwell/baytrail/cherrytrail devices diff --git a/sound/soc/sof/intel/shim.h b/sound/soc/sof/intel/shim.h --- a/sound/soc/sof/intel/shim.h +++ b/sound/soc/sof/intel/shim.h - * shim registers for byt, bsw, cht, hsw, bdw + * shim registers for byt, bsw, cht, bdw - * sst shim register bits for byt, bsw, cht hsw, bdw + * sst shim register bits for byt, bsw, cht, bdw -extern const struct snd_sof_dsp_ops sof_hsw_ops; -extern const struct sof_intel_dsp_desc hsw_chip_info; diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c -#if is_enabled(config_snd_soc_sof_haswell) -static const struct sof_dev_desc sof_acpi_haswell_desc = { - .machines = snd_soc_acpi_intel_haswell_machines, - .resindex_lpe_base = 0, - .resindex_pcicfg_base = 1, - .resindex_imr_base = -1, - .irqindex_host_ipc = 0, - .chip_info = &hsw_chip_info, - .default_fw_path = "intel/sof", - .default_tplg_path = "intel/sof-tplg", - .default_fw_filename = "sof-hsw.ri", - .nocodec_tplg_filename = "sof-hsw-nocodec.tplg", - .ops = &sof_hsw_ops, - .arch_ops = &sof_xtensa_arch_ops -}; -#endif - -#if is_enabled(config_snd_soc_sof_haswell) - { "int33c8", (unsigned long)&sof_acpi_haswell_desc }, -#endif
Audio
1fa44098b683312b426bd05f1bfc0b5b1fa7860a
pierre louis bossart
sound
soc
intel, sof
asoc: sof: intel: add namespace for hda_common
define namespace and include it in pci top-level module.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
3
9
8
--- diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c -export_symbol(sof_apl_ops); +export_symbol_ns(sof_apl_ops, snd_soc_sof_intel_hda_common); -export_symbol(apl_chip_info); +export_symbol_ns(apl_chip_info, snd_soc_sof_intel_hda_common); diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c -export_symbol(sof_cnl_ops); +export_symbol_ns(sof_cnl_ops, snd_soc_sof_intel_hda_common); -export_symbol(cnl_chip_info); +export_symbol_ns(cnl_chip_info, snd_soc_sof_intel_hda_common); -export_symbol(icl_chip_info); +export_symbol_ns(icl_chip_info, snd_soc_sof_intel_hda_common); -export_symbol(tgl_chip_info); +export_symbol_ns(tgl_chip_info, snd_soc_sof_intel_hda_common); -export_symbol(ehl_chip_info); +export_symbol_ns(ehl_chip_info, snd_soc_sof_intel_hda_common); -export_symbol(jsl_chip_info); +export_symbol_ns(jsl_chip_info, snd_soc_sof_intel_hda_common); diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c +module_import_ns(snd_soc_sof_intel_hda_common);
Audio
cf5629e4594c2164aa629d21a749c65ad594de95
pierre louis bossart
sound
soc
intel, sof
asoc: sof: intel: hda: add namespace for hda-codec functionality
define namespaces (one generic and one dedicated for i915) and include them in hdaudio top-level module.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
2
9
7
--- diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c -export_symbol(hda_codec_jack_wake_enable); -export_symbol(hda_codec_jack_check); +export_symbol_ns(hda_codec_jack_wake_enable, snd_soc_sof_hda_audio_codec); +export_symbol_ns(hda_codec_jack_check, snd_soc_sof_hda_audio_codec); -export_symbol(hda_codec_probe_bus); +export_symbol_ns(hda_codec_probe_bus, snd_soc_sof_hda_audio_codec); -export_symbol(hda_codec_i915_get); +export_symbol_ns(hda_codec_i915_get, snd_soc_sof_hda_audio_codec_i915); -export_symbol(hda_codec_i915_put); +export_symbol_ns(hda_codec_i915_put, snd_soc_sof_hda_audio_codec_i915); -export_symbol(hda_codec_i915_init); +export_symbol_ns(hda_codec_i915_init, snd_soc_sof_hda_audio_codec_i915); -export_symbol(hda_codec_i915_exit); +export_symbol_ns(hda_codec_i915_exit, snd_soc_sof_hda_audio_codec_i915); diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c +module_import_ns(snd_soc_sof_hda_audio_codec); +module_import_ns(snd_soc_sof_hda_audio_codec_i915);
Audio
5bd216c6a6b48d8ed0b3283bf7ba84fc3a566b25
pierre louis bossart
sound
soc
intel, sof
asoc: sof: move arch_ops under ops
the current structures are not well designed. we include xtensa information from the acpi and pci levels, but at the kconfig/module level everything xtensa related is included at the sof/intel level.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['h', 'c']
8
15
16
--- diff --git a/include/sound/sof.h b/include/sound/sof.h --- a/include/sound/sof.h +++ b/include/sound/sof.h - const struct sof_arch_ops *arch_ops; diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c + + .arch_ops = &sof_xtensa_arch_ops, diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c + + .arch_ops = &sof_xtensa_arch_ops, diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c + + .arch_ops = &sof_xtensa_arch_ops, + + .arch_ops = &sof_xtensa_arch_ops, + + .arch_ops = &sof_xtensa_arch_ops, diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c + + .arch_ops = &sof_xtensa_arch_ops, diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops - .arch_ops = &sof_xtensa_arch_ops diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h + + const struct sof_arch_ops *arch_ops; -#define sof_arch_ops(sdev) ((sdev)->pdata->desc->arch_ops) +#define sof_arch_ops(sdev) ((sdev)->pdata->desc->ops->arch_ops)
Audio
0f501c7cde4086d15c396a95c59631b05dbc0351
pierre louis bossart
include
sound
intel, sof
asoc: sof: intel: add namespace for xtensa
now that xtensa stuff is only referenced in intel stuff, define namespace and import it in intel byt/bdw/hdaudio modules
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add module namespace support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel']
['c']
4
4
1
--- diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c +module_import_ns(snd_soc_sof_xtensa); diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c +module_import_ns(snd_soc_sof_xtensa); diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c +module_import_ns(snd_soc_sof_xtensa); diff --git a/sound/soc/sof/xtensa/core.c b/sound/soc/sof/xtensa/core.c --- a/sound/soc/sof/xtensa/core.c +++ b/sound/soc/sof/xtensa/core.c -export_symbol(sof_xtensa_arch_ops); +export_symbol_ns(sof_xtensa_arch_ops, snd_soc_sof_xtensa);
Audio
068ac0db8637d3c188010ab8b9cc136f98fcd3df
pierre louis bossart
sound
soc
intel, sof, xtensa
asoc: sof: intel: hda: add idisp4 dai
tgl supports more than three idisp dai's. add support for idisp4 cpu dai.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add idisp4 dai
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'sof', 'intel', 'hda']
['c']
1
4
0
--- diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c +{ + .name = "idisp4 pin", + .ops = &hda_link_dai_ops, +},
Audio
e68d6696575e1af3f92125e842f2853708f34589
sathyanarayana nujella
sound
soc
intel, sof
asoc: soc-acpi: add _adr-based link descriptors
for soundwire support, we added a 'link_mask' to describe the pcb hardware layout. this helped form a signature that can be used as a first-order way of detecting the hardware and selecting the machine driver.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for soundwire-based machines
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'soc-acpi']
['h']
1
21
0
--- diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h --- a/include/sound/soc-acpi.h +++ b/include/sound/soc-acpi.h + * @link_mask: links enabled on the board + * @links: array of link _adr descriptors, null terminated + u32 link_mask; + const struct snd_soc_acpi_link_adr *links; +}; + +/** + * snd_soc_acpi_link_adr: acpi-based list of _adr, with a variable + * number of devices per link + * + * @mask: one bit set indicates the link this list applies to + * @num_adr: array_size of adr + * @adr: array of _adr (represented as u64). + */ + +struct snd_soc_acpi_link_adr { + const u32 mask; + const u32 num_adr; + const u64 *adr; + * @links: array of link _adr descriptors, null terminated. + const struct snd_soc_acpi_link_adr *links;
Audio
efb6f3159e874f09992b7318cea12e8e27e8389b
pierre louis bossart
include
sound
asoc: intel: common: soc-acpi: declare new tables for soundwire
we cannot really lump soundwire-based configurations into the same tables since the mechanisms to identify boards is based on link configurations and _adr instead of _hid for i2s, so define new tables
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for soundwire-based machines
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'soc-acpi']
['h']
1
6
0
--- diff --git a/include/sound/soc-acpi-intel-match.h b/include/sound/soc-acpi-intel-match.h --- a/include/sound/soc-acpi-intel-match.h +++ b/include/sound/soc-acpi-intel-match.h +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cfl_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_icl_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[]; +
Audio
cf61a42066eae88b4bb0e5528ec9f5f8e50c5343
pierre louis bossart
include
sound
asoc: sof: intel: reference soundwire machine lists
use static tables to automatically select the relevant configurations.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for soundwire-based machines
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'soc-acpi']
['c']
1
5
0
--- diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c + .alt_machines = snd_soc_acpi_intel_cnl_sdw_machines, + .alt_machines = snd_soc_acpi_intel_cfl_sdw_machines, + .alt_machines = snd_soc_acpi_intel_cml_sdw_machines, + .alt_machines = snd_soc_acpi_intel_icl_sdw_machines, + .alt_machines = snd_soc_acpi_intel_tgl_sdw_machines,
Audio
5732c0fc53eb45565c485a886d027c0b1f86d4c5
pierre louis bossart
sound
soc
sof
asoc: amd mmap_interleaved support
acp-i2s device support mmap_interleaved. added support for the same.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
amd mmap_interleaved support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
1
3
1
--- diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c + sndrv_pcm_info_mmap | sndrv_pcm_info_mmap_valid | - sndrv_pcm_info_pause | sndrv_pcm_info_resume, + sndrv_pcm_info_mmap | sndrv_pcm_info_mmap_valid | + sndrv_pcm_info_pause | sndrv_pcm_info_resume,
Audio
3d8cbeda38f1cc51733715f0a02b338b4f75fad0
ravulapati vishnu vardhan rao
sound
soc
amd, raven
asoc: amd: add acp3x tdm mode support
acp3x i2s (cpu dai) can act in normal i2s and tdm modes. added support for tdm mode. desired mode can be selected from asoc machine driver.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add acp3x tdm mode support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'amd']
['c', 'h']
2
23
6
--- diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c --- a/sound/soc/amd/raven/acp3x-i2s.c +++ b/sound/soc/amd/raven/acp3x-i2s.c - u32 val, reg_val, frmt_val, frm_len; + u32 val, reg_val, frmt_reg, frm_len; - reg_val = mmacp_bttdm_iter; - frmt_val = mmacp_bttdm_txfrmt; + switch (adata->i2s_instance) { + case i2s_bt_instance: + reg_val = mmacp_bttdm_iter; + frmt_reg = mmacp_bttdm_txfrmt; + break; + case i2s_sp_instance: + default: + reg_val = mmacp_i2stdm_iter; + frmt_reg = mmacp_i2stdm_txfrmt; + } - reg_val = mmacp_bttdm_irer; - frmt_val = mmacp_bttdm_rxfrmt; + switch (adata->i2s_instance) { + case i2s_bt_instance: + reg_val = mmacp_bttdm_irer; + frmt_reg = mmacp_bttdm_rxfrmt; + break; + case i2s_sp_instance: + default: + reg_val = mmacp_i2stdm_irer; + frmt_reg = mmacp_i2stdm_rxfrmt; + } - rv_writel(frm_len, adata->acp3x_base + frmt_val); + rv_writel(frm_len, adata->acp3x_base + frmt_reg); diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h + u16 i2s_instance;
Audio
a43ea44ddda94bc6c4dbe257fcbdeecde8cb06f1
ravulapati vishnu vardhan rao
sound
soc
amd, raven
asoc: codecs: add jz4770-codec driver
add jz4770-codec driver to support the internal codec found in the jz4770 soc from ingenic.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add jz4770-codec driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'codecs']
['c', 'kconfig', 'makefile']
3
962
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_jz4770_codec +config snd_soc_jz4770_codec + depends on mips || compile_test + select regmap + tristate "ingenic jz4770 internal codec" + help + enable support for the internal codec found in the jz4770 soc + from ingenic. + + this driver can also be built as a module. if so, the module + will be called snd-soc-jz4770-codec. + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-jz4770-codec-objs := jz4770.o +obj-$(config_snd_soc_jz4770_codec) += snd-soc-jz4770-codec.o diff --git a/sound/soc/codecs/jz4770.c b/sound/soc/codecs/jz4770.c --- /dev/null +++ b/sound/soc/codecs/jz4770.c +// spdx-license-identifier: gpl-2.0 +// +// ingenic jz4770 codec driver +// +// copyright (c) 2012, maarten ter huurne <maarten@treewalker.org> +// copyright (c) 2019, paul cercueil <paul@crapouillou.net> + +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <linux/time64.h> + +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dai.h> +#include <sound/soc-dapm.h> +#include <sound/tlv.h> + +#define icdc_rgadw_offset 0x00 +#define icdc_rgdata_offset 0x04 + +/* icdc internal register access control register(rgadw) */ +#define icdc_rgadw_rgwr bit(16) + +#define icdc_rgadw_rgaddr_offset 8 +#define icdc_rgadw_rgaddr_mask genmask(14, icdc_rgadw_rgaddr_offset) + +#define icdc_rgadw_rgdin_offset 0 +#define icdc_rgadw_rgdin_mask genmask(7, icdc_rgadw_rgdin_offset) + +/* icdc internal register data output register (rgdata)*/ +#define icdc_rgdata_irq bit(8) + +#define icdc_rgdata_rgdout_offset 0 +#define icdc_rgdata_rgdout_mask genmask(7, icdc_rgdata_rgdout_offset) + +/* internal register space, accessed through regmap */ +enum { + jz4770_codec_reg_sr, + jz4770_codec_reg_aicr_dac, + jz4770_codec_reg_aicr_adc, + jz4770_codec_reg_cr_lo, + jz4770_codec_reg_cr_hp, + + jz4770_codec_reg_missing_reg1, + + jz4770_codec_reg_cr_dac, + jz4770_codec_reg_cr_mic, + jz4770_codec_reg_cr_li, + jz4770_codec_reg_cr_adc, + jz4770_codec_reg_cr_mix, + jz4770_codec_reg_cr_vic, + jz4770_codec_reg_ccr, + jz4770_codec_reg_fcr_dac, + jz4770_codec_reg_fcr_adc, + jz4770_codec_reg_icr, + jz4770_codec_reg_imr, + jz4770_codec_reg_ifr, + jz4770_codec_reg_gcr_hpl, + jz4770_codec_reg_gcr_hpr, + jz4770_codec_reg_gcr_libyl, + jz4770_codec_reg_gcr_libyr, + jz4770_codec_reg_gcr_dacl, + jz4770_codec_reg_gcr_dacr, + jz4770_codec_reg_gcr_mic1, + jz4770_codec_reg_gcr_mic2, + jz4770_codec_reg_gcr_adcl, + jz4770_codec_reg_gcr_adcr, + + jz4770_codec_reg_missing_reg2, + + jz4770_codec_reg_gcr_mixadc, + jz4770_codec_reg_gcr_mixdac, + jz4770_codec_reg_agc1, + jz4770_codec_reg_agc2, + jz4770_codec_reg_agc3, + jz4770_codec_reg_agc4, + jz4770_codec_reg_agc5, +}; + +#define reg_aicr_dac_adwl_offset 6 +#define reg_aicr_dac_adwl_mask (0x3 << reg_aicr_dac_adwl_offset) +#define reg_aicr_dac_serial bit(1) +#define reg_aicr_dac_i2s bit(0) + +#define reg_aicr_adc_adwl_offset 6 +#define reg_aicr_adc_adwl_mask (0x3 << reg_aicr_adc_adwl_offset) +#define reg_aicr_adc_serial bit(1) +#define reg_aicr_adc_i2s bit(0) + +#define reg_cr_lo_mute_offset 7 +#define reg_cr_lo_sb_offset 4 +#define reg_cr_lo_sel_offset 0 +#define reg_cr_lo_sel_mask (0x3 << reg_cr_lo_sel_offset) + +#define reg_cr_hp_mute bit(7) +#define reg_cr_hp_load bit(6) +#define reg_cr_hp_sb_offset 4 +#define reg_cr_hp_sb_hpcm bit(3) +#define reg_cr_hp_sel_offset 0 +#define reg_cr_hp_sel_mask (0x3 << reg_cr_hp_sel_offset) + +#define reg_cr_dac_mute bit(7) +#define reg_cr_dac_mono bit(6) +#define reg_cr_dac_left_only bit(5) +#define reg_cr_dac_sb_offset 4 +#define reg_cr_dac_lrswap bit(3) + +#define reg_cr_mic_stereo_offset 7 +#define reg_cr_mic_idiff_offset 6 +#define reg_cr_mic_sb_mic2_offset 5 +#define reg_cr_mic_sb_mic1_offset 4 +#define reg_cr_mic_bias_v0_offset 1 +#define reg_cr_mic_bias_sb_offset 0 + +#define reg_cr_li_liby_offset 4 +#define reg_cr_li_sb_offset 0 + +#define reg_cr_adc_dmic_sel bit(7) +#define reg_cr_adc_mono bit(6) +#define reg_cr_adc_left_only bit(5) +#define reg_cr_adc_sb_offset 4 +#define reg_cr_adc_lrswap bit(3) +#define reg_cr_adc_in_sel_offset 0 +#define reg_cr_adc_in_sel_mask (0x3 << reg_cr_adc_in_sel_offset) + +#define reg_cr_vic_sb_sleep bit(1) +#define reg_cr_vic_sb bit(0) + +#define reg_ccr_crystal_offset 0 +#define reg_ccr_crystal_mask (0xf << reg_ccr_crystal_offset) + +#define reg_fcr_dac_freq_offset 0 +#define reg_fcr_dac_freq_mask (0xf << reg_fcr_dac_freq_offset) + +#define reg_fcr_adc_freq_offset 0 +#define reg_fcr_adc_freq_mask (0xf << reg_fcr_adc_freq_offset) + +#define reg_icr_int_form_offset 6 +#define reg_icr_int_form_mask (0x3 << reg_icr_int_form_offset) + +#define reg_imr_all_mask (0x7f) +#define reg_imr_sclr_mask bit(6) +#define reg_imr_jack_mask bit(5) +#define reg_imr_scmc_mask bit(4) +#define reg_imr_rup_mask bit(3) +#define reg_imr_rdo_mask bit(2) +#define reg_imr_gup_mask bit(1) +#define reg_imr_gdo_mask bit(0) + +#define reg_ifr_all_mask (0x7f) +#define reg_ifr_sclr bit(6) +#define reg_ifr_jack bit(5) +#define reg_ifr_scmc bit(4) +#define reg_ifr_rup bit(3) +#define reg_ifr_rdo bit(2) +#define reg_ifr_gup bit(1) +#define reg_ifr_gdo bit(0) + +#define reg_gcr_hpl_lrgo bit(7) + +#define reg_gcr_dacl_rlgod bit(7) + +#define reg_gcr_gain_offset 0 +#define reg_gcr_gain_max 0x1f + +#define reg_gcr_mic_gain_offset 0 +#define reg_gcr_mic_gain_max 5 + +#define reg_gcr_adc_gain_offset 0 +#define reg_gcr_adc_gain_max 23 + +#define reg_agc1_en bit(7) + +/* codec private data */ +struct jz_codec { + struct device *dev; + struct regmap *regmap; + void __iomem *base; + struct clk *clk; +}; + +static int jz4770_codec_set_bias_level(struct snd_soc_component *codec, + enum snd_soc_bias_level level) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + struct regmap *regmap = jz_codec->regmap; + + switch (level) { + case snd_soc_bias_prepare: + regmap_update_bits(regmap, jz4770_codec_reg_cr_vic, + reg_cr_vic_sb, 0); + msleep(250); + regmap_update_bits(regmap, jz4770_codec_reg_cr_vic, + reg_cr_vic_sb_sleep, 0); + msleep(400); + break; + case snd_soc_bias_standby: + regmap_update_bits(regmap, jz4770_codec_reg_cr_vic, + reg_cr_vic_sb_sleep, reg_cr_vic_sb_sleep); + regmap_update_bits(regmap, jz4770_codec_reg_cr_vic, + reg_cr_vic_sb, reg_cr_vic_sb); + /* fall-through */ + default: + break; + } + + return 0; +} + +static int jz4770_codec_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *codec = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + + /* + * sysclk output from the codec to the aic is required to keep the + * dma transfer going during playback when all audible outputs have + * been disabled. + */ + if (substream->stream == sndrv_pcm_stream_playback) + snd_soc_dapm_force_enable_pin(dapm, "sysclk"); + + return 0; +} + +static void jz4770_codec_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *codec = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + + if (substream->stream == sndrv_pcm_stream_playback) + snd_soc_dapm_disable_pin(dapm, "sysclk"); +} + + +static int jz4770_codec_pcm_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + struct snd_soc_component *codec = dai->component; + int ret = 0; + + switch (cmd) { + case sndrv_pcm_trigger_start: + case sndrv_pcm_trigger_resume: + case sndrv_pcm_trigger_pause_release: + if (substream->stream != sndrv_pcm_stream_playback) + snd_soc_component_force_bias_level(codec, + snd_soc_bias_on); + break; + case sndrv_pcm_trigger_stop: + case sndrv_pcm_trigger_suspend: + case sndrv_pcm_trigger_pause_push: + /* do nothing */ + break; + default: + ret = -einval; + } + + return ret; +} + +static int jz4770_codec_digital_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_component *codec = dai->component; + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + unsigned int gain_bit = mute ? reg_ifr_gdo : reg_ifr_gup; + unsigned int val; + int change, err; + + change = snd_soc_component_update_bits(codec, jz4770_codec_reg_cr_dac, + reg_cr_dac_mute, + mute ? reg_cr_dac_mute : 0); + if (change == 1) { + regmap_read(jz_codec->regmap, jz4770_codec_reg_cr_dac, &val); + + if (val & bit(reg_cr_dac_sb_offset)) + return 1; + + err = regmap_read_poll_timeout(jz_codec->regmap, + jz4770_codec_reg_ifr, + val, val & gain_bit, + 1000, 100 * usec_per_msec); + if (err) { + dev_err(jz_codec->dev, + "timeout while setting digital mute: %d", err); + return err; + } + + /* clear gup/gdo flag */ + regmap_update_bits(jz_codec->regmap, jz4770_codec_reg_ifr, + gain_bit, gain_bit); + } + + return 0; +} + +/* unit: 0.01db */ +static const declare_tlv_db_minmax_mute(dac_tlv, -3100, 0); +static const declare_tlv_db_scale(adc_tlv, 0, 100, 0); +static const declare_tlv_db_minmax(out_tlv, -2500, 600); +static const declare_tlv_db_scale(mic_boost_tlv, 0, 400, 0); +static const declare_tlv_db_scale(linein_tlv, -2500, 100, 0); + +/* unconditional controls. */ +static const struct snd_kcontrol_new jz4770_codec_snd_controls[] = { + /* record gain control */ + soc_double_r_tlv("pcm capture volume", + jz4770_codec_reg_gcr_adcl, jz4770_codec_reg_gcr_adcr, + reg_gcr_adc_gain_offset, reg_gcr_adc_gain_max, + 0, adc_tlv), + + soc_double_r_tlv("line in bypass playback volume", + jz4770_codec_reg_gcr_libyl, jz4770_codec_reg_gcr_libyr, + reg_gcr_gain_offset, reg_gcr_gain_max, 1, linein_tlv), +}; + +static const struct snd_kcontrol_new jz4770_codec_pcm_playback_controls[] = { + { + .iface = sndrv_ctl_elem_iface_mixer, + .name = "volume", + .info = snd_soc_info_volsw, + .access = sndrv_ctl_elem_access_tlv_read + | sndrv_ctl_elem_access_readwrite, + .tlv.p = dac_tlv, + .get = snd_soc_dapm_get_volsw, + .put = snd_soc_dapm_put_volsw, + /* + * note: dacr/dacl are inversed; the gain value written to dacr + * seems to affect the left channel, and the gain value written + * to dacl seems to affect the right channel. + */ + .private_value = soc_double_r_value(jz4770_codec_reg_gcr_dacr, + jz4770_codec_reg_gcr_dacl, + reg_gcr_gain_offset, + reg_gcr_gain_max, 1), + }, +}; + +static const struct snd_kcontrol_new jz4770_codec_hp_playback_controls[] = { + { + .iface = sndrv_ctl_elem_iface_mixer, + .name = "volume", + .info = snd_soc_info_volsw, + .access = sndrv_ctl_elem_access_tlv_read + | sndrv_ctl_elem_access_readwrite, + .tlv.p = out_tlv, + .get = snd_soc_dapm_get_volsw, + .put = snd_soc_dapm_put_volsw, + /* hpr/hpl inversed for the same reason as above */ + .private_value = soc_double_r_value(jz4770_codec_reg_gcr_hpr, + jz4770_codec_reg_gcr_hpl, + reg_gcr_gain_offset, + reg_gcr_gain_max, 1), + }, +}; + +static int hpout_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm); + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + unsigned int val; + int err; + + switch (event) { + case snd_soc_dapm_pre_pmu: + /* set cap-less, unmute hp */ + regmap_update_bits(jz_codec->regmap, jz4770_codec_reg_cr_hp, + reg_cr_hp_sb_hpcm | reg_cr_hp_mute, 0); + break; + + case snd_soc_dapm_post_pmu: + /* wait for ramp-up complete (rup) */ + err = regmap_read_poll_timeout(jz_codec->regmap, + jz4770_codec_reg_ifr, + val, val & reg_ifr_rup, + 1000, 100 * usec_per_msec); + if (err) { + dev_err(jz_codec->dev, "rup timeout: %d", err); + return err; + } + + /* clear rup flag */ + regmap_update_bits(jz_codec->regmap, jz4770_codec_reg_ifr, + reg_ifr_rup, reg_ifr_rup); + + break; + + case snd_soc_dapm_post_pmd: + /* set cap-couple, mute hp */ + regmap_update_bits(jz_codec->regmap, jz4770_codec_reg_cr_hp, + reg_cr_hp_sb_hpcm | reg_cr_hp_mute, + reg_cr_hp_sb_hpcm | reg_cr_hp_mute); + + err = regmap_read_poll_timeout(jz_codec->regmap, + jz4770_codec_reg_ifr, + val, val & reg_ifr_rdo, + 1000, 100 * usec_per_msec); + if (err) { + dev_err(jz_codec->dev, "rdo timeout: %d", err); + return err; + } + + /* clear rdo flag */ + regmap_update_bits(jz_codec->regmap, jz4770_codec_reg_ifr, + reg_ifr_rdo, reg_ifr_rdo); + + break; + } + + return 0; +} + +static int adc_poweron_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event == snd_soc_dapm_post_pmu) + msleep(1000); + + return 0; +} + +static const char * const jz4770_codec_hp_texts[] = { + "pcm", "line in", "mic 1", "mic 2" +}; +static const unsigned int jz4770_codec_hp_values[] = { 3, 2, 0, 1 }; +static soc_value_enum_single_decl(jz4770_codec_hp_enum, + jz4770_codec_reg_cr_hp, + reg_cr_hp_sel_offset, + reg_cr_hp_sel_mask, + jz4770_codec_hp_texts, + jz4770_codec_hp_values); +static const struct snd_kcontrol_new jz4770_codec_hp_source = + soc_dapm_enum("route", jz4770_codec_hp_enum); + +static soc_value_enum_single_decl(jz4770_codec_lo_enum, + jz4770_codec_reg_cr_lo, + reg_cr_lo_sel_offset, + reg_cr_lo_sel_mask, + jz4770_codec_hp_texts, + jz4770_codec_hp_values); +static const struct snd_kcontrol_new jz4770_codec_lo_source = + soc_dapm_enum("route", jz4770_codec_lo_enum); + +static const char * const jz4770_codec_cap_texts[] = { + "line in", "mic 1", "mic 2" +}; +static const unsigned int jz4770_codec_cap_values[] = { 2, 0, 1 }; +static soc_value_enum_single_decl(jz4770_codec_cap_enum, + jz4770_codec_reg_cr_adc, + reg_cr_adc_in_sel_offset, + reg_cr_adc_in_sel_mask, + jz4770_codec_cap_texts, + jz4770_codec_cap_values); +static const struct snd_kcontrol_new jz4770_codec_cap_source = + soc_dapm_enum("route", jz4770_codec_cap_enum); + +static const struct snd_kcontrol_new jz4770_codec_mic_controls[] = { + soc_dapm_single("stereo capture switch", jz4770_codec_reg_cr_mic, + reg_cr_mic_stereo_offset, 1, 0), +}; + +static const struct snd_soc_dapm_widget jz4770_codec_dapm_widgets[] = { + snd_soc_dapm_pga_e("hp out", jz4770_codec_reg_cr_hp, + reg_cr_hp_sb_offset, 1, null, 0, hpout_event, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_post_pmd), + + snd_soc_dapm_pga("line out", jz4770_codec_reg_cr_lo, + reg_cr_lo_sb_offset, 1, null, 0), + + snd_soc_dapm_pga("line out switch 2", jz4770_codec_reg_cr_lo, + reg_cr_lo_mute_offset, 1, null, 0), + + snd_soc_dapm_pga("line in", jz4770_codec_reg_cr_li, + reg_cr_li_sb_offset, 1, null, 0), + + snd_soc_dapm_mux("headphones source", snd_soc_nopm, 0, 0, + &jz4770_codec_hp_source), + snd_soc_dapm_mux("capture source", snd_soc_nopm, 0, 0, + &jz4770_codec_cap_source), + snd_soc_dapm_mux("line out source", snd_soc_nopm, 0, 0, + &jz4770_codec_lo_source), + + snd_soc_dapm_pga("mic 1", jz4770_codec_reg_cr_mic, + reg_cr_mic_sb_mic1_offset, 1, null, 0), + snd_soc_dapm_pga("mic 2", jz4770_codec_reg_cr_mic, + reg_cr_mic_sb_mic2_offset, 1, null, 0), + + snd_soc_dapm_pga("mic diff", jz4770_codec_reg_cr_mic, + reg_cr_mic_idiff_offset, 0, null, 0), + + snd_soc_dapm_mixer("mic", snd_soc_nopm, 0, 0, + jz4770_codec_mic_controls, + array_size(jz4770_codec_mic_controls)), + + snd_soc_dapm_pga("line in bypass", jz4770_codec_reg_cr_li, + reg_cr_li_liby_offset, 1, null, 0), + + snd_soc_dapm_adc_e("adc", "hifi capture", jz4770_codec_reg_cr_adc, + reg_cr_adc_sb_offset, 1, adc_poweron_event, + snd_soc_dapm_post_pmu), + snd_soc_dapm_dac("dac", "hifi playback", jz4770_codec_reg_cr_dac, + reg_cr_dac_sb_offset, 1), + + snd_soc_dapm_mixer("pcm playback", snd_soc_nopm, 0, 0, + jz4770_codec_pcm_playback_controls, + array_size(jz4770_codec_pcm_playback_controls)), + snd_soc_dapm_mixer("headphones playback", snd_soc_nopm, 0, 0, + jz4770_codec_hp_playback_controls, + array_size(jz4770_codec_hp_playback_controls)), + + snd_soc_dapm_supply("micbias", jz4770_codec_reg_cr_mic, + reg_cr_mic_bias_sb_offset, 1, null, 0), + + snd_soc_dapm_input("mic1p"), + snd_soc_dapm_input("mic1n"), + snd_soc_dapm_input("mic2p"), + snd_soc_dapm_input("mic2n"), + + snd_soc_dapm_output("lout"), + snd_soc_dapm_output("rout"), + + snd_soc_dapm_output("lhpout"), + snd_soc_dapm_output("rhpout"), + + snd_soc_dapm_input("llinein"), + snd_soc_dapm_input("rlinein"), + + snd_soc_dapm_output("sysclk"), +}; + +/* unconditional routes. */ +static const struct snd_soc_dapm_route jz4770_codec_dapm_routes[] = { + { "mic 1", null, "mic1p" }, + { "mic diff", null, "mic1n" }, + { "mic 1", null, "mic diff" }, + { "mic 2", null, "mic2p" }, + { "mic diff", null, "mic2n" }, + { "mic 2", null, "mic diff" }, + + { "line in", null, "llinein" }, + { "line in", null, "rlinein" }, + + { "mic", "stereo capture switch", "mic 1" }, + { "mic", "stereo capture switch", "mic 2" }, + { "headphones source", "mic 1", "mic" }, + { "headphones source", "mic 2", "mic" }, + { "capture source", "mic 1", "mic" }, + { "capture source", "mic 2", "mic" }, + + { "headphones source", "mic 1", "mic 1" }, + { "headphones source", "mic 2", "mic 2" }, + { "headphones source", "line in", "line in bypass" }, + { "headphones source", "pcm", "headphones playback" }, + { "hp out", null, "headphones source" }, + + { "capture source", "line in", "line in" }, + { "capture source", "mic 1", "mic 1" }, + { "capture source", "mic 2", "mic 2" }, + { "adc", null, "capture source" }, + + { "line in bypass", null, "line in" }, + { "line out source", "line in", "line in bypass" }, + { "line out source", "pcm", "pcm playback" }, + + { "lhpout", null, "hp out"}, + { "rhpout", null, "hp out"}, + + { "line out", null, "line out source" }, + { "line out switch 2", null, "line out" }, + + { "lout", null, "line out switch 2"}, + { "rout", null, "line out switch 2"}, + + { "pcm playback", "volume", "dac" }, + { "headphones playback", "volume", "pcm playback" }, + + { "sysclk", null, "dac" }, +}; + +static void jz4770_codec_codec_init_regs(struct snd_soc_component *codec) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + struct regmap *regmap = jz_codec->regmap; + + /* collect updates for later sending. */ + regcache_cache_only(regmap, true); + + /* default hp output to pcm */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_hp, + reg_cr_hp_sel_mask, reg_cr_hp_sel_mask); + + /* default line output to pcm */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_lo, + reg_cr_lo_sel_mask, reg_cr_lo_sel_mask); + + /* disable stereo mic */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_mic, + bit(reg_cr_mic_stereo_offset), 0); + + /* set mic 1 as default source for adc */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_adc, + reg_cr_adc_in_sel_mask, 0); + + /* adc/dac: serial + i2s */ + regmap_update_bits(regmap, jz4770_codec_reg_aicr_adc, + reg_aicr_adc_serial | reg_aicr_adc_i2s, + reg_aicr_adc_serial | reg_aicr_adc_i2s); + regmap_update_bits(regmap, jz4770_codec_reg_aicr_dac, + reg_aicr_dac_serial | reg_aicr_dac_i2s, + reg_aicr_dac_serial | reg_aicr_dac_i2s); + + /* the generated irq is a high level */ + regmap_update_bits(regmap, jz4770_codec_reg_icr, + reg_icr_int_form_mask, 0); + regmap_update_bits(regmap, jz4770_codec_reg_imr, reg_imr_all_mask, + reg_imr_jack_mask | reg_imr_rup_mask | + reg_imr_rdo_mask | reg_imr_gup_mask | + reg_imr_gdo_mask); + + /* 12m oscillator */ + regmap_update_bits(regmap, jz4770_codec_reg_ccr, + reg_ccr_crystal_mask, 0); + + /* 0: 16ohm/220uf, 1: 10kohm/1uf */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_hp, + reg_cr_hp_load, 0); + + /* disable automatic gain */ + regmap_update_bits(regmap, jz4770_codec_reg_agc1, reg_agc1_en, 0); + + /* disable dac lrswap */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_dac, + reg_cr_dac_lrswap, reg_cr_dac_lrswap); + + /* independent l/r dac gain control */ + regmap_update_bits(regmap, jz4770_codec_reg_gcr_dacl, + reg_gcr_dacl_rlgod, 0); + + /* disable adc lrswap */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_adc, + reg_cr_adc_lrswap, reg_cr_adc_lrswap); + + /* default to cap-less mode(0) */ + regmap_update_bits(regmap, jz4770_codec_reg_cr_hp, + reg_cr_hp_sb_hpcm, 0); + + /* send collected updates. */ + regcache_cache_only(regmap, false); + regcache_sync(regmap); + + /* reset all interrupt flags. */ + regmap_write(regmap, jz4770_codec_reg_ifr, reg_ifr_all_mask); +} + +static int jz4770_codec_codec_probe(struct snd_soc_component *codec) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + + clk_prepare_enable(jz_codec->clk); + + jz4770_codec_codec_init_regs(codec); + + return 0; +} + +static void jz4770_codec_codec_remove(struct snd_soc_component *codec) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + + clk_disable_unprepare(jz_codec->clk); +} + +static const struct snd_soc_component_driver jz4770_codec_soc_codec_dev = { + .probe = jz4770_codec_codec_probe, + .remove = jz4770_codec_codec_remove, + .set_bias_level = jz4770_codec_set_bias_level, + .controls = jz4770_codec_snd_controls, + .num_controls = array_size(jz4770_codec_snd_controls), + .dapm_widgets = jz4770_codec_dapm_widgets, + .num_dapm_widgets = array_size(jz4770_codec_dapm_widgets), + .dapm_routes = jz4770_codec_dapm_routes, + .num_dapm_routes = array_size(jz4770_codec_dapm_routes), + .suspend_bias_off = 1, + .use_pmdown_time = 1, +}; + +static const unsigned int jz4770_codec_sample_rates[] = { + 96000, 48000, 44100, 32000, + 24000, 22050, 16000, 12000, + 11025, 9600, 8000, +}; + +static int jz4770_codec_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct jz_codec *codec = snd_soc_component_get_drvdata(dai->component); + unsigned int rate, bit_width; + + switch (params_format(params)) { + case sndrv_pcm_format_s16_le: + bit_width = 0; + break; + case sndrv_pcm_format_s18_3le: + bit_width = 1; + break; + case sndrv_pcm_format_s20_3le: + bit_width = 2; + break; + case sndrv_pcm_format_s24_3le: + bit_width = 3; + break; + default: + return -einval; + } + + for (rate = 0; rate < array_size(jz4770_codec_sample_rates); rate++) { + if (jz4770_codec_sample_rates[rate] == params_rate(params)) + break; + } + + if (rate == array_size(jz4770_codec_sample_rates)) + return -einval; + + if (substream->stream == sndrv_pcm_stream_playback) { + regmap_update_bits(codec->regmap, jz4770_codec_reg_aicr_dac, + reg_aicr_dac_adwl_mask, + bit_width << reg_aicr_dac_adwl_offset); + regmap_update_bits(codec->regmap, jz4770_codec_reg_fcr_dac, + reg_fcr_dac_freq_mask, + rate << reg_fcr_dac_freq_offset); + } else { + regmap_update_bits(codec->regmap, jz4770_codec_reg_aicr_adc, + reg_aicr_adc_adwl_mask, + bit_width << reg_aicr_adc_adwl_offset); + regmap_update_bits(codec->regmap, jz4770_codec_reg_fcr_adc, + reg_fcr_adc_freq_mask, + rate << reg_fcr_adc_freq_offset); + } + + return 0; +} + +static const struct snd_soc_dai_ops jz4770_codec_dai_ops = { + .startup = jz4770_codec_startup, + .shutdown = jz4770_codec_shutdown, + .hw_params = jz4770_codec_hw_params, + .trigger = jz4770_codec_pcm_trigger, + .digital_mute = jz4770_codec_digital_mute, +}; + +#define jz_codec_formats (sndrv_pcm_fmtbit_s16_le | \ + sndrv_pcm_fmtbit_s18_3le | \ + sndrv_pcm_fmtbit_s20_3le | \ + sndrv_pcm_fmtbit_s24_3le) + +static struct snd_soc_dai_driver jz4770_codec_dai = { + .name = "jz4770-hifi", + .playback = { + .stream_name = "playback", + .channels_min = 2, + .channels_max = 2, + .rates = sndrv_pcm_rate_8000_96000, + .formats = jz_codec_formats, + }, + .capture = { + .stream_name = "capture", + .channels_min = 2, + .channels_max = 2, + .rates = sndrv_pcm_rate_8000_96000, + .formats = jz_codec_formats, + }, + .ops = &jz4770_codec_dai_ops, +}; + +static bool jz4770_codec_volatile(struct device *dev, unsigned int reg) +{ + return reg == jz4770_codec_reg_sr || reg == jz4770_codec_reg_ifr; +} + +static bool jz4770_codec_readable(struct device *dev, unsigned int reg) +{ + switch (reg) { + case jz4770_codec_reg_missing_reg1: + case jz4770_codec_reg_missing_reg2: + return false; + default: + return true; + } +} + +static bool jz4770_codec_writeable(struct device *dev, unsigned int reg) +{ + switch (reg) { + case jz4770_codec_reg_sr: + case jz4770_codec_reg_missing_reg1: + case jz4770_codec_reg_missing_reg2: + return false; + default: + return true; + } +} + +static int jz4770_codec_io_wait(struct jz_codec *codec) +{ + u32 reg; + + return readl_poll_timeout(codec->base + icdc_rgadw_offset, reg, + !(reg & icdc_rgadw_rgwr), + 1000, 10 * usec_per_msec); +} + +static int jz4770_codec_reg_read(void *context, unsigned int reg, + unsigned int *val) +{ + struct jz_codec *codec = context; + unsigned int i; + u32 tmp; + int ret; + + ret = jz4770_codec_io_wait(codec); + if (ret) + return ret; + + tmp = readl(codec->base + icdc_rgadw_offset); + tmp = (tmp & ~icdc_rgadw_rgaddr_mask) + | (reg << icdc_rgadw_rgaddr_offset); + writel(tmp, codec->base + icdc_rgadw_offset); + + /* wait 6+ cycles */ + for (i = 0; i < 6; i++) + *val = readl(codec->base + icdc_rgdata_offset) & + icdc_rgdata_rgdout_mask; + + return 0; +} + +static int jz4770_codec_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + struct jz_codec *codec = context; + int ret; + + ret = jz4770_codec_io_wait(codec); + if (ret) + return ret; + + writel(icdc_rgadw_rgwr | (reg << icdc_rgadw_rgaddr_offset) | val, + codec->base + icdc_rgadw_offset); + + ret = jz4770_codec_io_wait(codec); + if (ret) + return ret; + + return 0; +} + +static const u8 jz4770_codec_reg_defaults[] = { + 0x00, 0xc3, 0xc3, 0x90, 0x98, 0xff, 0x90, 0xb1, + 0x11, 0x10, 0x00, 0x03, 0x00, 0x00, 0x40, 0x00, + 0xff, 0x00, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x34, + 0x07, 0x44, 0x1f, 0x00 +}; + +static struct regmap_config jz4770_codec_regmap_config = { + .reg_bits = 7, + .val_bits = 8, + + .max_register = jz4770_codec_reg_agc5, + .volatile_reg = jz4770_codec_volatile, + .readable_reg = jz4770_codec_readable, + .writeable_reg = jz4770_codec_writeable, + + .reg_read = jz4770_codec_reg_read, + .reg_write = jz4770_codec_reg_write, + + .reg_defaults_raw = jz4770_codec_reg_defaults, + .num_reg_defaults_raw = array_size(jz4770_codec_reg_defaults), + .cache_type = regcache_flat, +}; + +static int jz4770_codec_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct jz_codec *codec; + int ret; + + codec = devm_kzalloc(dev, sizeof(*codec), gfp_kernel); + if (!codec) + return -enomem; + + codec->dev = dev; + + codec->base = devm_platform_ioremap_resource(pdev, 0); + if (is_err(codec->base)) { + ret = ptr_err(codec->base); + dev_err(dev, "failed to ioremap mmio memory: %d ", ret); + return ret; + } + + codec->regmap = devm_regmap_init(dev, null, codec, + &jz4770_codec_regmap_config); + if (is_err(codec->regmap)) + return ptr_err(codec->regmap); + + codec->clk = devm_clk_get(dev, "aic"); + if (is_err(codec->clk)) + return ptr_err(codec->clk); + + platform_set_drvdata(pdev, codec); + + ret = devm_snd_soc_register_component(dev, &jz4770_codec_soc_codec_dev, + &jz4770_codec_dai, 1); + if (ret) { + dev_err(dev, "failed to register codec: %d ", ret); + return ret; + } + + return 0; +} + +static const struct of_device_id jz4770_codec_of_matches[] = { + { .compatible = "ingenic,jz4770-codec", }, + { /* sentinel */ } +}; +module_device_table(of, jz4770_codec_of_matches); + +static struct platform_driver jz4770_codec_driver = { + .probe = jz4770_codec_probe, + .driver = { + .name = "jz4770-codec", + .of_match_table = of_match_ptr(jz4770_codec_of_matches), + }, +}; +module_platform_driver(jz4770_codec_driver); + +module_description("jz4770 soc internal codec driver"); +module_author("maarten ter huurne <maarten@treewalker.org>"); +module_author("paul cercueil <paul@crapouillou.net>"); +module_license("gpl v2");
Audio
2159a6810e96c38a469c39df8e109edb7232d3c9
paul cercueil
sound
soc
codecs
asoc: codecs: add wsa881x amplifier support
this patch adds support to wsa8810/wsa8815 class-d smart speaker amplifier. this amplifier is primarily interfaced with soundwire. one wsa is used for mono speaker configuration and second one would give stereo setup.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add wsa881x amplifier support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'codecs']
['c', 'kconfig', 'makefile']
3
1,197
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_wsa881x if soundwire +config snd_soc_wsa881x + tristate "wsa881x codec" + depends on soundwire + select regmap_soundwire + tristate + help + this enables support for qualcomm wsa8810/wsa8815 class-d + smart speaker amplifier. + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-wsa881x-objs := wsa881x.o +obj-$(config_snd_soc_wsa881x) += snd-soc-wsa881x.o diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c --- /dev/null +++ b/sound/soc/codecs/wsa881x.c +// spdx-license-identifier: gpl-2.0 +// copyright (c) 2015-2017, the linux foundation. +// copyright (c) 2019, linaro limited + +#include <linux/bitops.h> +#include <linux/gpio.h> +#include <linux/gpio/consumer.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/soundwire/sdw.h> +#include <linux/soundwire/sdw_registers.h> +#include <linux/soundwire/sdw_type.h> +#include <sound/soc.h> +#include <sound/tlv.h> + +#define wsa881x_digital_base 0x3000 +#define wsa881x_analog_base 0x3100 + +/* digital register address space */ +#define wsa881x_chip_id0 (wsa881x_digital_base + 0x0000) +#define wsa881x_chip_id1 (wsa881x_digital_base + 0x0001) +#define wsa881x_chip_id2 (wsa881x_digital_base + 0x0002) +#define wsa881x_chip_id3 (wsa881x_digital_base + 0x0003) +#define wsa881x_bus_id (wsa881x_digital_base + 0x0004) +#define wsa881x_cdc_rst_ctl (wsa881x_digital_base + 0x0005) +#define wsa881x_cdc_top_clk_ctl (wsa881x_digital_base + 0x0006) +#define wsa881x_cdc_ana_clk_ctl (wsa881x_digital_base + 0x0007) +#define wsa881x_cdc_dig_clk_ctl (wsa881x_digital_base + 0x0008) +#define wsa881x_clock_config (wsa881x_digital_base + 0x0009) +#define wsa881x_ana_ctl (wsa881x_digital_base + 0x000a) +#define wsa881x_swr_reset_en (wsa881x_digital_base + 0x000b) +#define wsa881x_reset_ctl (wsa881x_digital_base + 0x000c) +#define wsa881x_tadc_value_ctl (wsa881x_digital_base + 0x000f) +#define wsa881x_temp_detect_ctl (wsa881x_digital_base + 0x0010) +#define wsa881x_temp_msb (wsa881x_digital_base + 0x0011) +#define wsa881x_temp_lsb (wsa881x_digital_base + 0x0012) +#define wsa881x_temp_config0 (wsa881x_digital_base + 0x0013) +#define wsa881x_temp_config1 (wsa881x_digital_base + 0x0014) +#define wsa881x_cdc_clip_ctl (wsa881x_digital_base + 0x0015) +#define wsa881x_sdm_pdm9_lsb (wsa881x_digital_base + 0x0016) +#define wsa881x_sdm_pdm9_msb (wsa881x_digital_base + 0x0017) +#define wsa881x_cdc_rx_ctl (wsa881x_digital_base + 0x0018) +#define wsa881x_dem_bypass_data0 (wsa881x_digital_base + 0x0019) +#define wsa881x_dem_bypass_data1 (wsa881x_digital_base + 0x001a) +#define wsa881x_dem_bypass_data2 (wsa881x_digital_base + 0x001b) +#define wsa881x_dem_bypass_data3 (wsa881x_digital_base + 0x001c) +#define wsa881x_otp_ctrl0 (wsa881x_digital_base + 0x001d) +#define wsa881x_otp_ctrl1 (wsa881x_digital_base + 0x001e) +#define wsa881x_hdrive_ctl_group1 (wsa881x_digital_base + 0x001f) +#define wsa881x_intr_mode (wsa881x_digital_base + 0x0020) +#define wsa881x_intr_mask (wsa881x_digital_base + 0x0021) +#define wsa881x_intr_status (wsa881x_digital_base + 0x0022) +#define wsa881x_intr_clear (wsa881x_digital_base + 0x0023) +#define wsa881x_intr_level (wsa881x_digital_base + 0x0024) +#define wsa881x_intr_set (wsa881x_digital_base + 0x0025) +#define wsa881x_intr_test (wsa881x_digital_base + 0x0026) +#define wsa881x_pdm_test_mode (wsa881x_digital_base + 0x0030) +#define wsa881x_ate_test_mode (wsa881x_digital_base + 0x0031) +#define wsa881x_pin_ctl_mode (wsa881x_digital_base + 0x0032) +#define wsa881x_pin_ctl_oe (wsa881x_digital_base + 0x0033) +#define wsa881x_pin_wdata_iopad (wsa881x_digital_base + 0x0034) +#define wsa881x_pin_status (wsa881x_digital_base + 0x0035) +#define wsa881x_dig_debug_mode (wsa881x_digital_base + 0x0037) +#define wsa881x_dig_debug_sel (wsa881x_digital_base + 0x0038) +#define wsa881x_dig_debug_en (wsa881x_digital_base + 0x0039) +#define wsa881x_swr_hm_test1 (wsa881x_digital_base + 0x003b) +#define wsa881x_swr_hm_test2 (wsa881x_digital_base + 0x003c) +#define wsa881x_temp_detect_dbg_ctl (wsa881x_digital_base + 0x003d) +#define wsa881x_temp_debug_msb (wsa881x_digital_base + 0x003e) +#define wsa881x_temp_debug_lsb (wsa881x_digital_base + 0x003f) +#define wsa881x_sample_edge_sel (wsa881x_digital_base + 0x0044) +#define wsa881x_iopad_ctl (wsa881x_digital_base + 0x0045) +#define wsa881x_spare_0 (wsa881x_digital_base + 0x0050) +#define wsa881x_spare_1 (wsa881x_digital_base + 0x0051) +#define wsa881x_spare_2 (wsa881x_digital_base + 0x0052) +#define wsa881x_otp_reg_0 (wsa881x_digital_base + 0x0080) +#define wsa881x_otp_reg_1 (wsa881x_digital_base + 0x0081) +#define wsa881x_otp_reg_2 (wsa881x_digital_base + 0x0082) +#define wsa881x_otp_reg_3 (wsa881x_digital_base + 0x0083) +#define wsa881x_otp_reg_4 (wsa881x_digital_base + 0x0084) +#define wsa881x_otp_reg_5 (wsa881x_digital_base + 0x0085) +#define wsa881x_otp_reg_6 (wsa881x_digital_base + 0x0086) +#define wsa881x_otp_reg_7 (wsa881x_digital_base + 0x0087) +#define wsa881x_otp_reg_8 (wsa881x_digital_base + 0x0088) +#define wsa881x_otp_reg_9 (wsa881x_digital_base + 0x0089) +#define wsa881x_otp_reg_10 (wsa881x_digital_base + 0x008a) +#define wsa881x_otp_reg_11 (wsa881x_digital_base + 0x008b) +#define wsa881x_otp_reg_12 (wsa881x_digital_base + 0x008c) +#define wsa881x_otp_reg_13 (wsa881x_digital_base + 0x008d) +#define wsa881x_otp_reg_14 (wsa881x_digital_base + 0x008e) +#define wsa881x_otp_reg_15 (wsa881x_digital_base + 0x008f) +#define wsa881x_otp_reg_16 (wsa881x_digital_base + 0x0090) +#define wsa881x_otp_reg_17 (wsa881x_digital_base + 0x0091) +#define wsa881x_otp_reg_18 (wsa881x_digital_base + 0x0092) +#define wsa881x_otp_reg_19 (wsa881x_digital_base + 0x0093) +#define wsa881x_otp_reg_20 (wsa881x_digital_base + 0x0094) +#define wsa881x_otp_reg_21 (wsa881x_digital_base + 0x0095) +#define wsa881x_otp_reg_22 (wsa881x_digital_base + 0x0096) +#define wsa881x_otp_reg_23 (wsa881x_digital_base + 0x0097) +#define wsa881x_otp_reg_24 (wsa881x_digital_base + 0x0098) +#define wsa881x_otp_reg_25 (wsa881x_digital_base + 0x0099) +#define wsa881x_otp_reg_26 (wsa881x_digital_base + 0x009a) +#define wsa881x_otp_reg_27 (wsa881x_digital_base + 0x009b) +#define wsa881x_otp_reg_28 (wsa881x_digital_base + 0x009c) +#define wsa881x_otp_reg_29 (wsa881x_digital_base + 0x009d) +#define wsa881x_otp_reg_30 (wsa881x_digital_base + 0x009e) +#define wsa881x_otp_reg_31 (wsa881x_digital_base + 0x009f) +#define wsa881x_otp_reg_63 (wsa881x_digital_base + 0x00bf) + +/* analog register address space */ +#define wsa881x_bias_ref_ctrl (wsa881x_analog_base + 0x0000) +#define wsa881x_bias_test (wsa881x_analog_base + 0x0001) +#define wsa881x_bias_bias (wsa881x_analog_base + 0x0002) +#define wsa881x_temp_op (wsa881x_analog_base + 0x0003) +#define wsa881x_temp_iref_ctrl (wsa881x_analog_base + 0x0004) +#define wsa881x_temp_isens_ctrl (wsa881x_analog_base + 0x0005) +#define wsa881x_temp_clk_ctrl (wsa881x_analog_base + 0x0006) +#define wsa881x_temp_test (wsa881x_analog_base + 0x0007) +#define wsa881x_temp_bias (wsa881x_analog_base + 0x0008) +#define wsa881x_temp_adc_ctrl (wsa881x_analog_base + 0x0009) +#define wsa881x_temp_dout_msb (wsa881x_analog_base + 0x000a) +#define wsa881x_temp_dout_lsb (wsa881x_analog_base + 0x000b) +#define wsa881x_adc_en_modu_v (wsa881x_analog_base + 0x0010) +#define wsa881x_adc_en_modu_i (wsa881x_analog_base + 0x0011) +#define wsa881x_adc_en_det_test_v (wsa881x_analog_base + 0x0012) +#define wsa881x_adc_en_det_test_i (wsa881x_analog_base + 0x0013) +#define wsa881x_adc_sel_ibias (wsa881x_analog_base + 0x0014) +#define wsa881x_adc_en_sel_ibais (wsa881x_analog_base + 0x0015) +#define wsa881x_spkr_drv_en (wsa881x_analog_base + 0x001a) +#define wsa881x_spkr_drv_gain (wsa881x_analog_base + 0x001b) +#define wsa881x_pa_gain_sel_mask bit(3) +#define wsa881x_pa_gain_sel_reg bit(3) +#define wsa881x_pa_gain_sel_dre 0 +#define wsa881x_spkr_pag_gain_mask genmask(7, 4) +#define wsa881x_spkr_dac_ctl (wsa881x_analog_base + 0x001c) +#define wsa881x_spkr_drv_dbg (wsa881x_analog_base + 0x001d) +#define wsa881x_spkr_pwrstg_dbg (wsa881x_analog_base + 0x001e) +#define wsa881x_spkr_ocp_ctl (wsa881x_analog_base + 0x001f) +#define wsa881x_spkr_ocp_mask genmask(7, 6) +#define wsa881x_spkr_ocp_en bit(7) +#define wsa881x_spkr_ocp_hold bit(6) +#define wsa881x_spkr_clip_ctl (wsa881x_analog_base + 0x0020) +#define wsa881x_spkr_bbm_ctl (wsa881x_analog_base + 0x0021) +#define wsa881x_spkr_misc_ctl1 (wsa881x_analog_base + 0x0022) +#define wsa881x_spkr_misc_ctl2 (wsa881x_analog_base + 0x0023) +#define wsa881x_spkr_bias_int (wsa881x_analog_base + 0x0024) +#define wsa881x_spkr_pa_int (wsa881x_analog_base + 0x0025) +#define wsa881x_spkr_bias_cal (wsa881x_analog_base + 0x0026) +#define wsa881x_spkr_bias_psrr (wsa881x_analog_base + 0x0027) +#define wsa881x_spkr_status1 (wsa881x_analog_base + 0x0028) +#define wsa881x_spkr_status2 (wsa881x_analog_base + 0x0029) +#define wsa881x_boost_en_ctl (wsa881x_analog_base + 0x002a) +#define wsa881x_boost_en_mask bit(7) +#define wsa881x_boost_en bit(7) +#define wsa881x_boost_current_limit (wsa881x_analog_base + 0x002b) +#define wsa881x_boost_ps_ctl (wsa881x_analog_base + 0x002c) +#define wsa881x_boost_preset_out1 (wsa881x_analog_base + 0x002d) +#define wsa881x_boost_preset_out2 (wsa881x_analog_base + 0x002e) +#define wsa881x_boost_force_out (wsa881x_analog_base + 0x002f) +#define wsa881x_boost_ldo_prog (wsa881x_analog_base + 0x0030) +#define wsa881x_boost_slope_comp_isense_fb (wsa881x_analog_base + 0x0031) +#define wsa881x_boost_ron_ctl (wsa881x_analog_base + 0x0032) +#define wsa881x_boost_loop_stability (wsa881x_analog_base + 0x0033) +#define wsa881x_boost_zx_ctl (wsa881x_analog_base + 0x0034) +#define wsa881x_boost_start_ctl (wsa881x_analog_base + 0x0035) +#define wsa881x_boost_misc1_ctl (wsa881x_analog_base + 0x0036) +#define wsa881x_boost_misc2_ctl (wsa881x_analog_base + 0x0037) +#define wsa881x_boost_misc3_ctl (wsa881x_analog_base + 0x0038) +#define wsa881x_boost_atest_ctl (wsa881x_analog_base + 0x0039) +#define wsa881x_spkr_prot_fe_gain (wsa881x_analog_base + 0x003a) +#define wsa881x_spkr_prot_fe_cm_ldo_set (wsa881x_analog_base + 0x003b) +#define wsa881x_spkr_prot_fe_isense_bias_set1 (wsa881x_analog_base + 0x003c) +#define wsa881x_spkr_prot_fe_isense_bias_set2 (wsa881x_analog_base + 0x003d) +#define wsa881x_spkr_prot_atest1 (wsa881x_analog_base + 0x003e) +#define wsa881x_spkr_prot_atest2 (wsa881x_analog_base + 0x003f) +#define wsa881x_spkr_prot_fe_vsense_vcm (wsa881x_analog_base + 0x0040) +#define wsa881x_spkr_prot_fe_vsense_bias_set1 (wsa881x_analog_base + 0x0041) +#define wsa881x_bongo_resrv_reg1 (wsa881x_analog_base + 0x0042) +#define wsa881x_bongo_resrv_reg2 (wsa881x_analog_base + 0x0043) +#define wsa881x_spkr_prot_sar (wsa881x_analog_base + 0x0044) +#define wsa881x_spkr_status3 (wsa881x_analog_base + 0x0045) + +#define swrs_scp_frame_ctrl_bank(m) (0x60 + 0x10 * (m)) +#define swrs_scp_host_clk_div2_ctl_bank(m) (0xe0 + 0x10 * (m)) +#define swr_slv_max_reg_addr 0x390 +#define swr_slv_start_reg_addr 0x40 +#define swr_slv_max_buf_len 20 +#define bytes_per_line 12 +#define swr_slv_rd_buf_len 8 +#define swr_slv_wr_buf_len 32 +#define swr_slv_max_devices 2 +#define wsa881x_max_swr_ports 4 +#define wsa881x_version_entry_size 27 +#define wsa881x_ocp_ctl_timer_sec 2 +#define wsa881x_ocp_ctl_temp_celsius 25 +#define wsa881x_ocp_ctl_poll_timer_sec 60 + +#define wsa881x_pa_gain_tlv(xname, reg, shift, max, invert, tlv_array) \ +{ .iface = sndrv_ctl_elem_iface_mixer, .name = xname, \ + .access = sndrv_ctl_elem_access_tlv_read |\ + sndrv_ctl_elem_access_readwrite,\ + .tlv.p = (tlv_array), \ + .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ + .put = wsa881x_put_pa_gain, \ + .private_value = soc_single_value(reg, shift, max, invert, 0) } + +static struct reg_default wsa881x_defaults[] = { + { wsa881x_chip_id0, 0x00 }, + { wsa881x_chip_id1, 0x00 }, + { wsa881x_chip_id2, 0x00 }, + { wsa881x_chip_id3, 0x02 }, + { wsa881x_bus_id, 0x00 }, + { wsa881x_cdc_rst_ctl, 0x00 }, + { wsa881x_cdc_top_clk_ctl, 0x03 }, + { wsa881x_cdc_ana_clk_ctl, 0x00 }, + { wsa881x_cdc_dig_clk_ctl, 0x00 }, + { wsa881x_clock_config, 0x00 }, + { wsa881x_ana_ctl, 0x08 }, + { wsa881x_swr_reset_en, 0x00 }, + { wsa881x_temp_detect_ctl, 0x01 }, + { wsa881x_temp_msb, 0x00 }, + { wsa881x_temp_lsb, 0x00 }, + { wsa881x_temp_config0, 0x00 }, + { wsa881x_temp_config1, 0x00 }, + { wsa881x_cdc_clip_ctl, 0x03 }, + { wsa881x_sdm_pdm9_lsb, 0x00 }, + { wsa881x_sdm_pdm9_msb, 0x00 }, + { wsa881x_cdc_rx_ctl, 0x7e }, + { wsa881x_dem_bypass_data0, 0x00 }, + { wsa881x_dem_bypass_data1, 0x00 }, + { wsa881x_dem_bypass_data2, 0x00 }, + { wsa881x_dem_bypass_data3, 0x00 }, + { wsa881x_otp_ctrl0, 0x00 }, + { wsa881x_otp_ctrl1, 0x00 }, + { wsa881x_hdrive_ctl_group1, 0x00 }, + { wsa881x_intr_mode, 0x00 }, + { wsa881x_intr_status, 0x00 }, + { wsa881x_intr_clear, 0x00 }, + { wsa881x_intr_level, 0x00 }, + { wsa881x_intr_set, 0x00 }, + { wsa881x_intr_test, 0x00 }, + { wsa881x_pdm_test_mode, 0x00 }, + { wsa881x_ate_test_mode, 0x00 }, + { wsa881x_pin_ctl_mode, 0x00 }, + { wsa881x_pin_ctl_oe, 0x00 }, + { wsa881x_pin_wdata_iopad, 0x00 }, + { wsa881x_pin_status, 0x00 }, + { wsa881x_dig_debug_mode, 0x00 }, + { wsa881x_dig_debug_sel, 0x00 }, + { wsa881x_dig_debug_en, 0x00 }, + { wsa881x_swr_hm_test1, 0x08 }, + { wsa881x_swr_hm_test2, 0x00 }, + { wsa881x_temp_detect_dbg_ctl, 0x00 }, + { wsa881x_temp_debug_msb, 0x00 }, + { wsa881x_temp_debug_lsb, 0x00 }, + { wsa881x_sample_edge_sel, 0x0c }, + { wsa881x_spare_0, 0x00 }, + { wsa881x_spare_1, 0x00 }, + { wsa881x_spare_2, 0x00 }, + { wsa881x_otp_reg_0, 0x01 }, + { wsa881x_otp_reg_1, 0xff }, + { wsa881x_otp_reg_2, 0xc0 }, + { wsa881x_otp_reg_3, 0xff }, + { wsa881x_otp_reg_4, 0xc0 }, + { wsa881x_otp_reg_5, 0xff }, + { wsa881x_otp_reg_6, 0xff }, + { wsa881x_otp_reg_7, 0xff }, + { wsa881x_otp_reg_8, 0xff }, + { wsa881x_otp_reg_9, 0xff }, + { wsa881x_otp_reg_10, 0xff }, + { wsa881x_otp_reg_11, 0xff }, + { wsa881x_otp_reg_12, 0xff }, + { wsa881x_otp_reg_13, 0xff }, + { wsa881x_otp_reg_14, 0xff }, + { wsa881x_otp_reg_15, 0xff }, + { wsa881x_otp_reg_16, 0xff }, + { wsa881x_otp_reg_17, 0xff }, + { wsa881x_otp_reg_18, 0xff }, + { wsa881x_otp_reg_19, 0xff }, + { wsa881x_otp_reg_20, 0xff }, + { wsa881x_otp_reg_21, 0xff }, + { wsa881x_otp_reg_22, 0xff }, + { wsa881x_otp_reg_23, 0xff }, + { wsa881x_otp_reg_24, 0x03 }, + { wsa881x_otp_reg_25, 0x01 }, + { wsa881x_otp_reg_26, 0x03 }, + { wsa881x_otp_reg_27, 0x11 }, + { wsa881x_otp_reg_63, 0x40 }, + /* wsa881x analog registers */ + { wsa881x_bias_ref_ctrl, 0x6c }, + { wsa881x_bias_test, 0x16 }, + { wsa881x_bias_bias, 0xf0 }, + { wsa881x_temp_op, 0x00 }, + { wsa881x_temp_iref_ctrl, 0x56 }, + { wsa881x_temp_isens_ctrl, 0x47 }, + { wsa881x_temp_clk_ctrl, 0x87 }, + { wsa881x_temp_test, 0x00 }, + { wsa881x_temp_bias, 0x51 }, + { wsa881x_temp_dout_msb, 0x00 }, + { wsa881x_temp_dout_lsb, 0x00 }, + { wsa881x_adc_en_modu_v, 0x00 }, + { wsa881x_adc_en_modu_i, 0x00 }, + { wsa881x_adc_en_det_test_v, 0x00 }, + { wsa881x_adc_en_det_test_i, 0x00 }, + { wsa881x_adc_en_sel_ibais, 0x10 }, + { wsa881x_spkr_drv_en, 0x74 }, + { wsa881x_spkr_drv_dbg, 0x15 }, + { wsa881x_spkr_pwrstg_dbg, 0x00 }, + { wsa881x_spkr_ocp_ctl, 0xd4 }, + { wsa881x_spkr_clip_ctl, 0x90 }, + { wsa881x_spkr_pa_int, 0x54 }, + { wsa881x_spkr_bias_cal, 0xac }, + { wsa881x_spkr_status1, 0x00 }, + { wsa881x_spkr_status2, 0x00 }, + { wsa881x_boost_en_ctl, 0x18 }, + { wsa881x_boost_current_limit, 0x7a }, + { wsa881x_boost_preset_out2, 0x70 }, + { wsa881x_boost_force_out, 0x0e }, + { wsa881x_boost_ldo_prog, 0x16 }, + { wsa881x_boost_slope_comp_isense_fb, 0x71 }, + { wsa881x_boost_ron_ctl, 0x0f }, + { wsa881x_boost_zx_ctl, 0x34 }, + { wsa881x_boost_start_ctl, 0x23 }, + { wsa881x_boost_misc1_ctl, 0x80 }, + { wsa881x_boost_misc2_ctl, 0x00 }, + { wsa881x_boost_misc3_ctl, 0x00 }, + { wsa881x_boost_atest_ctl, 0x00 }, + { wsa881x_spkr_prot_fe_gain, 0x46 }, + { wsa881x_spkr_prot_fe_cm_ldo_set, 0x3b }, + { wsa881x_spkr_prot_fe_isense_bias_set1, 0x8d }, + { wsa881x_spkr_prot_fe_isense_bias_set2, 0x8d }, + { wsa881x_spkr_prot_atest1, 0x01 }, + { wsa881x_spkr_prot_fe_vsense_vcm, 0x8d }, + { wsa881x_spkr_prot_fe_vsense_bias_set1, 0x4d }, + { wsa881x_spkr_prot_sar, 0x00 }, + { wsa881x_spkr_status3, 0x00 }, +}; + +static const struct reg_sequence wsa881x_pre_pmu_pa_2_0[] = { + { wsa881x_spkr_drv_gain, 0x41, 0 }, + { wsa881x_spkr_misc_ctl1, 0x87, 0 }, +}; + +static const struct reg_sequence wsa881x_vi_txfe_en_2_0[] = { + { wsa881x_spkr_prot_fe_vsense_vcm, 0x85, 0 }, + { wsa881x_spkr_prot_atest2, 0x0a, 0 }, + { wsa881x_spkr_prot_fe_gain, 0x47, 0 }, +}; + +/* default register reset values for wsa881x rev 2.0 */ +static struct reg_sequence wsa881x_rev_2_0[] = { + { wsa881x_reset_ctl, 0x00, 0x00 }, + { wsa881x_tadc_value_ctl, 0x01, 0x00 }, + { wsa881x_intr_mask, 0x1b, 0x00 }, + { wsa881x_iopad_ctl, 0x00, 0x00 }, + { wsa881x_otp_reg_28, 0x3f, 0x00 }, + { wsa881x_otp_reg_29, 0x3f, 0x00 }, + { wsa881x_otp_reg_30, 0x01, 0x00 }, + { wsa881x_otp_reg_31, 0x01, 0x00 }, + { wsa881x_temp_adc_ctrl, 0x03, 0x00 }, + { wsa881x_adc_sel_ibias, 0x45, 0x00 }, + { wsa881x_spkr_drv_gain, 0xc1, 0x00 }, + { wsa881x_spkr_dac_ctl, 0x42, 0x00 }, + { wsa881x_spkr_bbm_ctl, 0x02, 0x00 }, + { wsa881x_spkr_misc_ctl1, 0x40, 0x00 }, + { wsa881x_spkr_misc_ctl2, 0x07, 0x00 }, + { wsa881x_spkr_bias_int, 0x5f, 0x00 }, + { wsa881x_spkr_bias_psrr, 0x44, 0x00 }, + { wsa881x_boost_ps_ctl, 0xa0, 0x00 }, + { wsa881x_boost_preset_out1, 0xb7, 0x00 }, + { wsa881x_boost_loop_stability, 0x8d, 0x00 }, + { wsa881x_spkr_prot_atest2, 0x02, 0x00 }, + { wsa881x_bongo_resrv_reg1, 0x5e, 0x00 }, + { wsa881x_bongo_resrv_reg2, 0x07, 0x00 }, +}; + +enum wsa_port_ids { + wsa881x_port_dac, + wsa881x_port_comp, + wsa881x_port_boost, + wsa881x_port_visense, +}; + +/* 4 ports */ +static struct sdw_dpn_prop wsa_sink_dpn_prop[wsa881x_max_swr_ports] = { + { + /* dac */ + .num = 1, + .type = sdw_dpn_simple, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + }, { + /* comp */ + .num = 2, + .type = sdw_dpn_simple, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + }, { + /* boost */ + .num = 3, + .type = sdw_dpn_simple, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + }, { + /* visense */ + .num = 4, + .type = sdw_dpn_simple, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + } +}; + +static struct sdw_port_config wsa881x_pconfig[wsa881x_max_swr_ports] = { + { + .num = 1, + .ch_mask = 0x1, + }, { + .num = 2, + .ch_mask = 0xf, + }, { + .num = 3, + .ch_mask = 0x3, + }, { /* iv feedback */ + .num = 4, + .ch_mask = 0x3, + }, +}; + +static bool wsa881x_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case wsa881x_chip_id0: + case wsa881x_chip_id1: + case wsa881x_chip_id2: + case wsa881x_chip_id3: + case wsa881x_bus_id: + case wsa881x_cdc_rst_ctl: + case wsa881x_cdc_top_clk_ctl: + case wsa881x_cdc_ana_clk_ctl: + case wsa881x_cdc_dig_clk_ctl: + case wsa881x_clock_config: + case wsa881x_ana_ctl: + case wsa881x_swr_reset_en: + case wsa881x_reset_ctl: + case wsa881x_tadc_value_ctl: + case wsa881x_temp_detect_ctl: + case wsa881x_temp_msb: + case wsa881x_temp_lsb: + case wsa881x_temp_config0: + case wsa881x_temp_config1: + case wsa881x_cdc_clip_ctl: + case wsa881x_sdm_pdm9_lsb: + case wsa881x_sdm_pdm9_msb: + case wsa881x_cdc_rx_ctl: + case wsa881x_dem_bypass_data0: + case wsa881x_dem_bypass_data1: + case wsa881x_dem_bypass_data2: + case wsa881x_dem_bypass_data3: + case wsa881x_otp_ctrl0: + case wsa881x_otp_ctrl1: + case wsa881x_hdrive_ctl_group1: + case wsa881x_intr_mode: + case wsa881x_intr_mask: + case wsa881x_intr_status: + case wsa881x_intr_clear: + case wsa881x_intr_level: + case wsa881x_intr_set: + case wsa881x_intr_test: + case wsa881x_pdm_test_mode: + case wsa881x_ate_test_mode: + case wsa881x_pin_ctl_mode: + case wsa881x_pin_ctl_oe: + case wsa881x_pin_wdata_iopad: + case wsa881x_pin_status: + case wsa881x_dig_debug_mode: + case wsa881x_dig_debug_sel: + case wsa881x_dig_debug_en: + case wsa881x_swr_hm_test1: + case wsa881x_swr_hm_test2: + case wsa881x_temp_detect_dbg_ctl: + case wsa881x_temp_debug_msb: + case wsa881x_temp_debug_lsb: + case wsa881x_sample_edge_sel: + case wsa881x_iopad_ctl: + case wsa881x_spare_0: + case wsa881x_spare_1: + case wsa881x_spare_2: + case wsa881x_otp_reg_0: + case wsa881x_otp_reg_1: + case wsa881x_otp_reg_2: + case wsa881x_otp_reg_3: + case wsa881x_otp_reg_4: + case wsa881x_otp_reg_5: + case wsa881x_otp_reg_6: + case wsa881x_otp_reg_7: + case wsa881x_otp_reg_8: + case wsa881x_otp_reg_9: + case wsa881x_otp_reg_10: + case wsa881x_otp_reg_11: + case wsa881x_otp_reg_12: + case wsa881x_otp_reg_13: + case wsa881x_otp_reg_14: + case wsa881x_otp_reg_15: + case wsa881x_otp_reg_16: + case wsa881x_otp_reg_17: + case wsa881x_otp_reg_18: + case wsa881x_otp_reg_19: + case wsa881x_otp_reg_20: + case wsa881x_otp_reg_21: + case wsa881x_otp_reg_22: + case wsa881x_otp_reg_23: + case wsa881x_otp_reg_24: + case wsa881x_otp_reg_25: + case wsa881x_otp_reg_26: + case wsa881x_otp_reg_27: + case wsa881x_otp_reg_28: + case wsa881x_otp_reg_29: + case wsa881x_otp_reg_30: + case wsa881x_otp_reg_31: + case wsa881x_otp_reg_63: + case wsa881x_bias_ref_ctrl: + case wsa881x_bias_test: + case wsa881x_bias_bias: + case wsa881x_temp_op: + case wsa881x_temp_iref_ctrl: + case wsa881x_temp_isens_ctrl: + case wsa881x_temp_clk_ctrl: + case wsa881x_temp_test: + case wsa881x_temp_bias: + case wsa881x_temp_adc_ctrl: + case wsa881x_temp_dout_msb: + case wsa881x_temp_dout_lsb: + case wsa881x_adc_en_modu_v: + case wsa881x_adc_en_modu_i: + case wsa881x_adc_en_det_test_v: + case wsa881x_adc_en_det_test_i: + case wsa881x_adc_sel_ibias: + case wsa881x_adc_en_sel_ibais: + case wsa881x_spkr_drv_en: + case wsa881x_spkr_drv_gain: + case wsa881x_spkr_dac_ctl: + case wsa881x_spkr_drv_dbg: + case wsa881x_spkr_pwrstg_dbg: + case wsa881x_spkr_ocp_ctl: + case wsa881x_spkr_clip_ctl: + case wsa881x_spkr_bbm_ctl: + case wsa881x_spkr_misc_ctl1: + case wsa881x_spkr_misc_ctl2: + case wsa881x_spkr_bias_int: + case wsa881x_spkr_pa_int: + case wsa881x_spkr_bias_cal: + case wsa881x_spkr_bias_psrr: + case wsa881x_spkr_status1: + case wsa881x_spkr_status2: + case wsa881x_boost_en_ctl: + case wsa881x_boost_current_limit: + case wsa881x_boost_ps_ctl: + case wsa881x_boost_preset_out1: + case wsa881x_boost_preset_out2: + case wsa881x_boost_force_out: + case wsa881x_boost_ldo_prog: + case wsa881x_boost_slope_comp_isense_fb: + case wsa881x_boost_ron_ctl: + case wsa881x_boost_loop_stability: + case wsa881x_boost_zx_ctl: + case wsa881x_boost_start_ctl: + case wsa881x_boost_misc1_ctl: + case wsa881x_boost_misc2_ctl: + case wsa881x_boost_misc3_ctl: + case wsa881x_boost_atest_ctl: + case wsa881x_spkr_prot_fe_gain: + case wsa881x_spkr_prot_fe_cm_ldo_set: + case wsa881x_spkr_prot_fe_isense_bias_set1: + case wsa881x_spkr_prot_fe_isense_bias_set2: + case wsa881x_spkr_prot_atest1: + case wsa881x_spkr_prot_atest2: + case wsa881x_spkr_prot_fe_vsense_vcm: + case wsa881x_spkr_prot_fe_vsense_bias_set1: + case wsa881x_bongo_resrv_reg1: + case wsa881x_bongo_resrv_reg2: + case wsa881x_spkr_prot_sar: + case wsa881x_spkr_status3: + return true; + default: + return false; + } +} + +static bool wsa881x_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case wsa881x_chip_id0: + case wsa881x_chip_id1: + case wsa881x_chip_id2: + case wsa881x_chip_id3: + case wsa881x_bus_id: + case wsa881x_temp_msb: + case wsa881x_temp_lsb: + case wsa881x_sdm_pdm9_lsb: + case wsa881x_sdm_pdm9_msb: + case wsa881x_otp_ctrl1: + case wsa881x_intr_status: + case wsa881x_ate_test_mode: + case wsa881x_pin_status: + case wsa881x_swr_hm_test2: + case wsa881x_spkr_status1: + case wsa881x_spkr_status2: + case wsa881x_spkr_status3: + case wsa881x_otp_reg_0: + case wsa881x_otp_reg_1: + case wsa881x_otp_reg_2: + case wsa881x_otp_reg_3: + case wsa881x_otp_reg_4: + case wsa881x_otp_reg_5: + case wsa881x_otp_reg_31: + case wsa881x_temp_dout_msb: + case wsa881x_temp_dout_lsb: + case wsa881x_temp_op: + case wsa881x_spkr_prot_sar: + return true; + default: + return false; + } +} + +static struct regmap_config wsa881x_regmap_config = { + .reg_bits = 32, + .val_bits = 8, + .cache_type = regcache_rbtree, + .reg_defaults = wsa881x_defaults, + .num_reg_defaults = array_size(wsa881x_defaults), + .volatile_reg = wsa881x_volatile_register, + .readable_reg = wsa881x_readable_register, + .reg_format_endian = regmap_endian_native, + .val_format_endian = regmap_endian_native, + .can_multi_write = true, +}; + +enum { + g_18db = 0, + g_16p5db, + g_15db, + g_13p5db, + g_12db, + g_10p5db, + g_9db, + g_7p5db, + g_6db, + g_4p5db, + g_3db, + g_1p5db, + g_0db, +}; + +/* + * private data structure for wsa881x. all parameters related to + * wsa881x codec needs to be defined here. + */ +struct wsa881x_priv { + struct regmap *regmap; + struct device *dev; + struct sdw_slave *slave; + struct sdw_stream_config sconfig; + struct sdw_stream_runtime *sruntime; + struct sdw_port_config port_config[wsa881x_max_swr_ports]; + struct gpio_desc *sd_n; + int version; + int active_ports; + bool port_prepared[wsa881x_max_swr_ports]; + bool port_enable[wsa881x_max_swr_ports]; + bool stream_prepared; +}; + +static void wsa881x_init(struct wsa881x_priv *wsa881x) +{ + struct regmap *rm = wsa881x->regmap; + unsigned int val = 0; + + regmap_read(rm, wsa881x_chip_id1, &wsa881x->version); + regmap_register_patch(wsa881x->regmap, wsa881x_rev_2_0, + array_size(wsa881x_rev_2_0)); + + /* enable software reset output from soundwire slave */ + regmap_update_bits(rm, wsa881x_swr_reset_en, 0x07, 0x07); + + /* bring out of analog reset */ + regmap_update_bits(rm, wsa881x_cdc_rst_ctl, 0x02, 0x02); + + /* bring out of digital reset */ + regmap_update_bits(rm, wsa881x_cdc_rst_ctl, 0x01, 0x01); + regmap_update_bits(rm, wsa881x_clock_config, 0x10, 0x10); + regmap_update_bits(rm, wsa881x_spkr_ocp_ctl, 0x02, 0x02); + regmap_update_bits(rm, wsa881x_spkr_misc_ctl1, 0xc0, 0x80); + regmap_update_bits(rm, wsa881x_spkr_misc_ctl1, 0x06, 0x06); + regmap_update_bits(rm, wsa881x_spkr_bias_int, 0xff, 0x00); + regmap_update_bits(rm, wsa881x_spkr_pa_int, 0xf0, 0x40); + regmap_update_bits(rm, wsa881x_spkr_pa_int, 0x0e, 0x0e); + regmap_update_bits(rm, wsa881x_boost_loop_stability, 0x03, 0x03); + regmap_update_bits(rm, wsa881x_boost_misc2_ctl, 0xff, 0x14); + regmap_update_bits(rm, wsa881x_boost_start_ctl, 0x80, 0x80); + regmap_update_bits(rm, wsa881x_boost_start_ctl, 0x03, 0x00); + regmap_update_bits(rm, wsa881x_boost_slope_comp_isense_fb, 0x0c, 0x04); + regmap_update_bits(rm, wsa881x_boost_slope_comp_isense_fb, 0x03, 0x00); + + regmap_read(rm, wsa881x_otp_reg_0, &val); + if (val) + regmap_update_bits(rm, wsa881x_boost_preset_out1, 0xf0, 0x70); + + regmap_update_bits(rm, wsa881x_boost_preset_out2, 0xf0, 0x30); + regmap_update_bits(rm, wsa881x_spkr_drv_en, 0x08, 0x08); + regmap_update_bits(rm, wsa881x_boost_current_limit, 0x0f, 0x08); + regmap_update_bits(rm, wsa881x_spkr_ocp_ctl, 0x30, 0x30); + regmap_update_bits(rm, wsa881x_spkr_ocp_ctl, 0x0c, 0x00); + regmap_update_bits(rm, wsa881x_otp_reg_28, 0x3f, 0x3a); + regmap_update_bits(rm, wsa881x_bongo_resrv_reg1, 0xff, 0xb2); + regmap_update_bits(rm, wsa881x_bongo_resrv_reg2, 0xff, 0x05); +} + +static int wsa881x_component_probe(struct snd_soc_component *comp) +{ + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp); + + snd_soc_component_init_regmap(comp, wsa881x->regmap); + + return 0; +} + +static int wsa881x_put_pa_gain(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *comp = snd_soc_kcontrol_component(kc); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kc->private_value; + int max = mc->max; + unsigned int mask = (1 << fls(max)) - 1; + int val, ret, min_gain, max_gain; + + max_gain = (max - ucontrol->value.integer.value[0]) & mask; + /* + * gain has to set incrementally in 4 steps + * as per hw sequence + */ + if (max_gain > g_4p5db) + min_gain = g_0db; + else + min_gain = max_gain + 3; + /* + * 1ms delay is needed before change in gain + * as per hw requirement. + */ + usleep_range(1000, 1010); + + for (val = min_gain; max_gain <= val; val--) { + ret = snd_soc_component_update_bits(comp, + wsa881x_spkr_drv_gain, + wsa881x_spkr_pag_gain_mask, + val << 4); + if (ret < 0) + dev_err(comp->dev, "failed to change pa gain"); + + usleep_range(1000, 1010); + } + return 0; +} + +static int wsa881x_get_port(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *data = snd_soc_component_get_drvdata(comp); + struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kcontrol->private_value; + int portidx = mixer->reg; + + ucontrol->value.integer.value[0] = data->port_enable[portidx]; + + + return 0; +} + +static int wsa881x_boost_ctrl(struct snd_soc_component *comp, bool enable) +{ + if (enable) + snd_soc_component_update_bits(comp, wsa881x_boost_en_ctl, + wsa881x_boost_en_mask, + wsa881x_boost_en); + else + snd_soc_component_update_bits(comp, wsa881x_boost_en_ctl, + wsa881x_boost_en_mask, 0); + /* + * 1.5ms sleep is needed after boost enable/disable as per + * hw requirement + */ + usleep_range(1500, 1510); + return 0; +} + +static int wsa881x_set_port(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *data = snd_soc_component_get_drvdata(comp); + struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kcontrol->private_value; + int portidx = mixer->reg; + + if (ucontrol->value.integer.value[0]) + data->port_enable[portidx] = true; + else + data->port_enable[portidx] = false; + + if (portidx == wsa881x_port_boost) /* boost switch */ + wsa881x_boost_ctrl(comp, data->port_enable[portidx]); + + return 0; +} + +static const char * const smart_boost_lvl_text[] = { + "6.625 v", "6.750 v", "6.875 v", "7.000 v", + "7.125 v", "7.250 v", "7.375 v", "7.500 v", + "7.625 v", "7.750 v", "7.875 v", "8.000 v", + "8.125 v", "8.250 v", "8.375 v", "8.500 v" +}; + +static const struct soc_enum smart_boost_lvl_enum = + soc_enum_single(wsa881x_boost_preset_out1, 0, + array_size(smart_boost_lvl_text), + smart_boost_lvl_text); + +static const declare_tlv_db_scale(pa_gain, 0, 150, 0); + +static const struct snd_kcontrol_new wsa881x_snd_controls[] = { + soc_enum("smart boost level", smart_boost_lvl_enum), + wsa881x_pa_gain_tlv("pa volume", wsa881x_spkr_drv_gain, + 4, 0xc, 1, pa_gain), + soc_single_ext("dac switch", wsa881x_port_dac, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), + soc_single_ext("comp switch", wsa881x_port_comp, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), + soc_single_ext("boost switch", wsa881x_port_boost, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), + soc_single_ext("visense switch", wsa881x_port_visense, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), +}; + +static const struct snd_soc_dapm_route wsa881x_audio_map[] = { + { "rdac", null, "in" }, + { "rdac", null, "dclk" }, + { "rdac", null, "aclk" }, + { "rdac", null, "bandgap" }, + { "spkr pga", null, "rdac" }, + { "spkr", null, "spkr pga" }, +}; + +static int wsa881x_visense_txfe_ctrl(struct snd_soc_component *comp, + bool enable) +{ + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp); + + if (enable) { + regmap_multi_reg_write(wsa881x->regmap, wsa881x_vi_txfe_en_2_0, + array_size(wsa881x_vi_txfe_en_2_0)); + } else { + snd_soc_component_update_bits(comp, + wsa881x_spkr_prot_fe_vsense_vcm, + 0x08, 0x08); + /* + * 200us sleep is needed after visense txfe disable as per + * hw requirement. + */ + usleep_range(200, 210); + snd_soc_component_update_bits(comp, wsa881x_spkr_prot_fe_gain, + 0x01, 0x00); + } + return 0; +} + +static int wsa881x_visense_adc_ctrl(struct snd_soc_component *comp, + bool enable) +{ + snd_soc_component_update_bits(comp, wsa881x_adc_en_modu_v, bit(7), + (enable << 7)); + snd_soc_component_update_bits(comp, wsa881x_adc_en_modu_i, bit(7), + (enable << 7)); + return 0; +} + +static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp); + + switch (event) { + case snd_soc_dapm_pre_pmu: + snd_soc_component_update_bits(comp, wsa881x_spkr_ocp_ctl, + wsa881x_spkr_ocp_mask, + wsa881x_spkr_ocp_en); + regmap_multi_reg_write(wsa881x->regmap, wsa881x_pre_pmu_pa_2_0, + array_size(wsa881x_pre_pmu_pa_2_0)); + + snd_soc_component_update_bits(comp, wsa881x_spkr_drv_gain, + wsa881x_pa_gain_sel_mask, + wsa881x_pa_gain_sel_reg); + break; + case snd_soc_dapm_post_pmu: + if (wsa881x->port_prepared[wsa881x_port_visense]) { + wsa881x_visense_txfe_ctrl(comp, true); + snd_soc_component_update_bits(comp, + wsa881x_adc_en_sel_ibais, + 0x07, 0x01); + wsa881x_visense_adc_ctrl(comp, true); + } + + break; + case snd_soc_dapm_post_pmd: + if (wsa881x->port_prepared[wsa881x_port_visense]) { + wsa881x_visense_adc_ctrl(comp, false); + wsa881x_visense_txfe_ctrl(comp, false); + } + + snd_soc_component_update_bits(comp, wsa881x_spkr_ocp_ctl, + wsa881x_spkr_ocp_mask, + wsa881x_spkr_ocp_en | + wsa881x_spkr_ocp_hold); + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget wsa881x_dapm_widgets[] = { + snd_soc_dapm_input("in"), + snd_soc_dapm_dac_e("rdac", null, wsa881x_spkr_dac_ctl, 7, 0, + null, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd), + snd_soc_dapm_pga_e("spkr pga", snd_soc_nopm, 0, 0, null, 0, + wsa881x_spkr_pa_event, snd_soc_dapm_pre_pmu | + snd_soc_dapm_post_pmu | snd_soc_dapm_post_pmd), + snd_soc_dapm_supply("dclk", wsa881x_cdc_dig_clk_ctl, 0, 0, null, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd), + snd_soc_dapm_supply("aclk", wsa881x_cdc_ana_clk_ctl, 0, 0, null, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd), + snd_soc_dapm_supply("bandgap", wsa881x_temp_op, 3, 0, + null, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd), + snd_soc_dapm_output("spkr"), +}; + +static int wsa881x_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + int ret; + + if (wsa881x->stream_prepared) { + sdw_disable_stream(wsa881x->sruntime); + sdw_deprepare_stream(wsa881x->sruntime); + wsa881x->stream_prepared = false; + } + + + ret = sdw_prepare_stream(wsa881x->sruntime); + if (ret) + return ret; + + /** + * note: there is a strict hw requirement about the ordering of port + * enables and actual pa enable. pa enable should only happen after + * soundwire ports are enabled if not dc on the line is accumulated + * resulting in click/pop noise + * pa enable/mute are handled as part of dapm and digital mute. + */ + + ret = sdw_enable_stream(wsa881x->sruntime); + if (ret) { + sdw_deprepare_stream(wsa881x->sruntime); + return ret; + } + wsa881x->stream_prepared = true; + + return ret; +} + +static int wsa881x_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + int i; + + wsa881x->active_ports = 0; + for (i = 0; i < wsa881x_max_swr_ports; i++) { + if (!wsa881x->port_enable[i]) + continue; + + wsa881x->port_config[wsa881x->active_ports] = + wsa881x_pconfig[i]; + wsa881x->active_ports++; + } + + return sdw_stream_add_slave(wsa881x->slave, &wsa881x->sconfig, + wsa881x->port_config, wsa881x->active_ports, + wsa881x->sruntime); +} + +static int wsa881x_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + + if (wsa881x->stream_prepared) { + sdw_disable_stream(wsa881x->sruntime); + sdw_deprepare_stream(wsa881x->sruntime); + sdw_stream_remove_slave(wsa881x->slave, wsa881x->sruntime); + wsa881x->stream_prepared = false; + } + + return 0; +} + +static int wsa881x_set_sdw_stream(struct snd_soc_dai *dai, + void *stream, int direction) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + + wsa881x->sruntime = stream; + + return 0; +} + +static int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + + if (mute) + regmap_update_bits(wsa881x->regmap, wsa881x_spkr_drv_en, 0x80, + 0x00); + else + regmap_update_bits(wsa881x->regmap, wsa881x_spkr_drv_en, 0x80, + 0x80); + + return 0; +} + +static struct snd_soc_dai_ops wsa881x_dai_ops = { + .hw_params = wsa881x_hw_params, + .prepare = wsa881x_prepare, + .hw_free = wsa881x_hw_free, + .mute_stream = wsa881x_digital_mute, + .set_sdw_stream = wsa881x_set_sdw_stream, +}; + +static struct snd_soc_dai_driver wsa881x_dais[] = { + { + .name = "spkr", + .id = 0, + .playback = { + .stream_name = "spkr playback", + .rate_max = 48000, + .rate_min = 48000, + .channels_min = 1, + .channels_max = 1, + }, + .ops = &wsa881x_dai_ops, + }, +}; + +static const struct snd_soc_component_driver wsa881x_component_drv = { + .name = "wsa881x", + .probe = wsa881x_component_probe, + .controls = wsa881x_snd_controls, + .num_controls = array_size(wsa881x_snd_controls), + .dapm_widgets = wsa881x_dapm_widgets, + .num_dapm_widgets = array_size(wsa881x_dapm_widgets), + .dapm_routes = wsa881x_audio_map, + .num_dapm_routes = array_size(wsa881x_audio_map), +}; + +static int wsa881x_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(&slave->dev); + + if (status == sdw_slave_attached && slave->dev_num > 0) + wsa881x_init(wsa881x); + + return 0; +} + +static int wsa881x_port_prep(struct sdw_slave *slave, + struct sdw_prepare_ch *prepare_ch, + enum sdw_port_prep_ops state) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(&slave->dev); + + if (state == sdw_ops_port_post_prep) + wsa881x->port_prepared[prepare_ch->num - 1] = true; + else + wsa881x->port_prepared[prepare_ch->num - 1] = false; + + return 0; +} + +static int wsa881x_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + sdw_write(slave, swrs_scp_host_clk_div2_ctl_bank(params->next_bank), + 0x01); + + return 0; +} + +static struct sdw_slave_ops wsa881x_slave_ops = { + .update_status = wsa881x_update_status, + .bus_config = wsa881x_bus_config, + .port_prep = wsa881x_port_prep, +}; + +static int wsa881x_probe(struct sdw_slave *pdev, + const struct sdw_device_id *id) +{ + struct wsa881x_priv *wsa881x; + + wsa881x = devm_kzalloc(&pdev->dev, sizeof(*wsa881x), gfp_kernel); + if (!wsa881x) + return -enomem; + + wsa881x->sd_n = devm_gpiod_get_optional(&pdev->dev, "powerdown", + gpiod_flags_bit_nonexclusive); + if (is_err(wsa881x->sd_n)) { + dev_err(&pdev->dev, "shutdown control gpio not found "); + return ptr_err(wsa881x->sd_n); + } + + dev_set_drvdata(&pdev->dev, wsa881x); + wsa881x->slave = pdev; + wsa881x->dev = &pdev->dev; + wsa881x->sconfig.ch_count = 1; + wsa881x->sconfig.bps = 1; + wsa881x->sconfig.frame_rate = 48000; + wsa881x->sconfig.direction = sdw_data_dir_rx; + wsa881x->sconfig.type = sdw_stream_pdm; + pdev->prop.sink_ports = genmask(wsa881x_max_swr_ports, 0); + pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; + gpiod_set_value(wsa881x->sd_n, 1); + + wsa881x->regmap = devm_regmap_init_sdw(pdev, &wsa881x_regmap_config); + if (is_err(wsa881x->regmap)) { + dev_err(&pdev->dev, "regmap_init failed "); + return ptr_err(wsa881x->regmap); + } + + return devm_snd_soc_register_component(&pdev->dev, + &wsa881x_component_drv, + wsa881x_dais, + array_size(wsa881x_dais)); +} + +static const struct sdw_device_id wsa881x_slave_id[] = { + sdw_slave_entry(0x0217, 0x2010, 0), + sdw_slave_entry(0x0217, 0x2110, 0), + {}, +}; +module_device_table(sdw, wsa881x_slave_id); + +static struct sdw_driver wsa881x_codec_driver = { + .probe = wsa881x_probe, + .ops = &wsa881x_slave_ops, + .id_table = wsa881x_slave_id, + .driver = { + .name = "wsa881x-codec", + } +}; +module_sdw_driver(wsa881x_codec_driver); + +module_description("wsa881x codec driver"); +module_license("gpl v2");
Audio
a0aab9e1404ac9f8a300b4546cac3c38e04d07bf
srinivas kandagatla
sound
soc
codecs
asoc: fsl_asrc: add support for imx8qm & imx8qxp
there are two asrc module in imx8qm & imx8qxp, each module has different clock configuration, and the dma type is edma.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for imx8qm & imx8qxp
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'fsl_asrc']
['c', 'h']
3
194
36
--- diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c -static unsigned char input_clk_map_imx35[] = { +static unsigned char input_clk_map_imx35[asrc_clk_map_len] = { + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -static unsigned char output_clk_map_imx35[] = { +static unsigned char output_clk_map_imx35[asrc_clk_map_len] = { + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -static unsigned char input_clk_map_imx53[] = { +static unsigned char input_clk_map_imx53[asrc_clk_map_len] = { + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, -static unsigned char output_clk_map_imx53[] = { +static unsigned char output_clk_map_imx53[asrc_clk_map_len] = { + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, -static unsigned char *clk_map[2]; +/** + * i.mx8qm/i.mx8qxp uses the same map for input and output. + * clk_map_imx8qm[0] is for i.mx8qm asrc0 + * clk_map_imx8qm[1] is for i.mx8qm asrc1 + * clk_map_imx8qxp[0] is for i.mx8qxp asrc0 + * clk_map_imx8qxp[1] is for i.mx8qxp asrc1 + */ +static unsigned char clk_map_imx8qm[2][asrc_clk_map_len] = { + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0xb, 0xc, 0xf, 0xf, 0xd, 0xe, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + 0x4, 0x5, 0x6, 0xf, 0x8, 0x9, 0xa, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, +}; + +static unsigned char clk_map_imx8qxp[2][asrc_clk_map_len] = { + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xf, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xf, 0xf, + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0x7, 0x8, 0xf, 0xf, 0x9, 0xa, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + 0xf, 0xf, 0x6, 0xf, 0xf, 0xf, 0xa, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, +}; - clk_index[in] = clk_map[in][config->inclk]; - clk_index[out] = clk_map[out][config->outclk]; + clk_index[in] = asrc_priv->clk_map[in][config->inclk]; + clk_index[out] = asrc_priv->clk_map[out][config->outclk]; - if (asrc_priv->channel_bits < 4) + if (asrc_priv->soc->channel_bits < 4) - asrcncr_anci_mask(index, asrc_priv->channel_bits), - asrcncr_anci(index, channels, asrc_priv->channel_bits)); + asrcncr_anci_mask(index, asrc_priv->soc->channel_bits), + asrcncr_anci(index, channels, asrc_priv->soc->channel_bits)); - if (asrc_priv->channel_bits == 3) + if (asrc_priv->soc->channel_bits == 3) + u32 map_idx; + asrc_priv->soc = of_device_get_match_data(&pdev->dev); + if (!asrc_priv->soc) { + dev_err(&pdev->dev, "failed to get soc data "); + return -enodev; + } + - asrc_priv->channel_bits = 3; - clk_map[in] = input_clk_map_imx35; - clk_map[out] = output_clk_map_imx35; - } else { - asrc_priv->channel_bits = 4; - clk_map[in] = input_clk_map_imx53; - clk_map[out] = output_clk_map_imx53; + asrc_priv->clk_map[in] = input_clk_map_imx35; + asrc_priv->clk_map[out] = output_clk_map_imx35; + } else if (of_device_is_compatible(np, "fsl,imx53-asrc")) { + asrc_priv->clk_map[in] = input_clk_map_imx53; + asrc_priv->clk_map[out] = output_clk_map_imx53; + } else if (of_device_is_compatible(np, "fsl,imx8qm-asrc") || + of_device_is_compatible(np, "fsl,imx8qxp-asrc")) { + ret = of_property_read_u32(np, "fsl,asrc-clk-map", &map_idx); + if (ret) { + dev_err(&pdev->dev, "failed to get clk map index "); + return ret; + } + + if (map_idx > 1) { + dev_err(&pdev->dev, "unsupported clk map index "); + return -einval; + } + if (of_device_is_compatible(np, "fsl,imx8qm-asrc")) { + asrc_priv->clk_map[in] = clk_map_imx8qm[map_idx]; + asrc_priv->clk_map[out] = clk_map_imx8qm[map_idx]; + } else { + asrc_priv->clk_map[in] = clk_map_imx8qxp[map_idx]; + asrc_priv->clk_map[out] = clk_map_imx8qxp[map_idx]; + } +static const struct fsl_asrc_soc_data fsl_asrc_imx35_data = { + .use_edma = false, + .channel_bits = 3, +}; + +static const struct fsl_asrc_soc_data fsl_asrc_imx53_data = { + .use_edma = false, + .channel_bits = 4, +}; + +static const struct fsl_asrc_soc_data fsl_asrc_imx8qm_data = { + .use_edma = true, + .channel_bits = 4, +}; + +static const struct fsl_asrc_soc_data fsl_asrc_imx8qxp_data = { + .use_edma = true, + .channel_bits = 4, +}; + - { .compatible = "fsl,imx35-asrc", }, - { .compatible = "fsl,imx53-asrc", }, + { .compatible = "fsl,imx35-asrc", .data = &fsl_asrc_imx35_data }, + { .compatible = "fsl,imx53-asrc", .data = &fsl_asrc_imx53_data }, + { .compatible = "fsl,imx8qm-asrc", .data = &fsl_asrc_imx8qm_data }, + { .compatible = "fsl,imx8qxp-asrc", .data = &fsl_asrc_imx8qxp_data }, diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h + + /* clocks for imx8 */ + inclk_aud_pll_div_clk0 = 0x10, + inclk_aud_pll_div_clk1 = 0x11, + inclk_aud_clk0 = 0x12, + inclk_aud_clk1 = 0x13, + inclk_esai0_rx_clk = 0x14, + inclk_esai0_tx_clk = 0x15, + inclk_spdif0_rx = 0x16, + inclk_spdif1_rx = 0x17, + inclk_sai0_rx_bclk = 0x18, + inclk_sai0_tx_bclk = 0x19, + inclk_sai1_rx_bclk = 0x1a, + inclk_sai1_tx_bclk = 0x1b, + inclk_sai2_rx_bclk = 0x1c, + inclk_sai3_rx_bclk = 0x1d, + inclk_asrc0_mux_clk = 0x1e, + + inclk_esai1_rx_clk = 0x20, + inclk_esai1_tx_clk = 0x21, + inclk_sai6_tx_bclk = 0x22, + inclk_hdmi_rx_sai0_rx_bclk = 0x24, + inclk_hdmi_tx_sai0_tx_bclk = 0x25, + + /* clocks for imx8 */ + outclk_aud_pll_div_clk0 = 0x10, + outclk_aud_pll_div_clk1 = 0x11, + outclk_aud_clk0 = 0x12, + outclk_aud_clk1 = 0x13, + outclk_esai0_rx_clk = 0x14, + outclk_esai0_tx_clk = 0x15, + outclk_spdif0_rx = 0x16, + outclk_spdif1_rx = 0x17, + outclk_sai0_rx_bclk = 0x18, + outclk_sai0_tx_bclk = 0x19, + outclk_sai1_rx_bclk = 0x1a, + outclk_sai1_tx_bclk = 0x1b, + outclk_sai2_rx_bclk = 0x1c, + outclk_sai3_rx_bclk = 0x1d, + outclk_asrco_mux_clk = 0x1e, + + outclk_esai1_rx_clk = 0x20, + outclk_esai1_tx_clk = 0x21, + outclk_sai6_tx_bclk = 0x22, + outclk_hdmi_rx_sai0_rx_bclk = 0x24, + outclk_hdmi_tx_sai0_tx_bclk = 0x25, +#define asrc_clk_map_len 0x30 +/** + * fsl_asrc_soc_data: soc specific data + * + * @use_edma: using edma as dma device or not + * @channel_bits: width of asrcncr register for each pair + */ +struct fsl_asrc_soc_data { + bool use_edma; + unsigned int channel_bits; +}; + - * @channel_bits: width of asrcncr register for each pair + * @soc: soc specific data + * @clk_map: clock map for input/output clock - unsigned int channel_bits; + const struct fsl_asrc_soc_data *soc; + unsigned char *clk_map[2]; diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c - /* get dma request of back-end */ - tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx"); - tmp_data = tmp_chan->private; - pair->dma_data.dma_request = tmp_data->dma_request; - dma_release_channel(tmp_chan); - - /* get dma request of front-end */ - tmp_chan = fsl_asrc_get_dma_channel(pair, dir); - tmp_data = tmp_chan->private; - pair->dma_data.dma_request2 = tmp_data->dma_request; - pair->dma_data.peripheral_type = tmp_data->peripheral_type; - pair->dma_data.priority = tmp_data->priority; - dma_release_channel(tmp_chan); + /* + * an edma dev_to_dev channel is fixed and bound with dma event of each + * peripheral, unlike sdma channel that is allocated dynamically. so no + * need to configure dma_request and dma_request2, but get dma_chan via + * dma_request_slave_channel directly with dma name of front-end device + */ + if (!asrc_priv->soc->use_edma) { + /* get dma request of back-end */ + tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx"); + tmp_data = tmp_chan->private; + pair->dma_data.dma_request = tmp_data->dma_request; + dma_release_channel(tmp_chan); + + /* get dma request of front-end */ + tmp_chan = fsl_asrc_get_dma_channel(pair, dir); + tmp_data = tmp_chan->private; + pair->dma_data.dma_request2 = tmp_data->dma_request; + pair->dma_data.peripheral_type = tmp_data->peripheral_type; + pair->dma_data.priority = tmp_data->priority; + dma_release_channel(tmp_chan); + + pair->dma_chan[dir] = + dma_request_channel(mask, filter, &pair->dma_data); + } else { + pair->dma_chan[dir] = + fsl_asrc_get_dma_channel(pair, dir); + } - pair->dma_chan[dir] = dma_request_channel(mask, filter, &pair->dma_data);
Audio
c05f10f28ef697aae8f1d82012d660af3cfc8cf9
shengjiu wang
sound
soc
fsl
asoc: gtm601: add broadmobi bm818 sound profile
the broadmobi bm818 uses stereo sound at 48khz sample rate
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add broadmobi bm818 sound profile
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'gtm601']
['c']
1
27
3
--- diff --git a/sound/soc/codecs/gtm601.c b/sound/soc/codecs/gtm601.c --- a/sound/soc/codecs/gtm601.c +++ b/sound/soc/codecs/gtm601.c -#include <linux/device.h> +#include <linux/of_device.h> +static struct snd_soc_dai_driver bm818_dai = { + .name = "bm818", + .playback = { + .stream_name = "playback", + .channels_min = 2, + .channels_max = 2, + .rates = sndrv_pcm_rate_48000, + .formats = sndrv_pcm_fmtbit_s16_le, + }, + .capture = { + .stream_name = "capture", + .channels_min = 2, + .channels_max = 2, + .rates = sndrv_pcm_rate_48000, + .formats = sndrv_pcm_fmtbit_s16_le, + }, +}; + + const struct snd_soc_dai_driver *dai_driver; + + dai_driver = of_device_get_match_data(&pdev->dev); + - &soc_component_dev_gtm601, &gtm601_dai, 1); + &soc_component_dev_gtm601, + (struct snd_soc_dai_driver *)dai_driver, 1); - { .compatible = "option,gtm601", }, + { .compatible = "option,gtm601", .data = (void *)&gtm601_dai }, + { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai },
Audio
057a317a8d94136b76a3cc6f7be53ee2b85dc115
angus ainslie purism
sound
soc
codecs
asoc: intel/skl/hda - export number of digital microphones via control components
it is required for the auto-detection in the user space (for ucm).
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
intel/skl/hda - export number of digital microphones via control components
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ']
['c']
2
10
1
--- diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c --- a/sound/soc/intel/boards/skl_hda_dsp_generic.c +++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c +static char hda_soc_components[30]; + + if (mach->mach_params.dmic_num > 0) { + snprintf(hda_soc_components, sizeof(hda_soc_components), + "cfg-dmics:%d", mach->mach_params.dmic_num); + hda_soc_card.components = hda_soc_components; + } + diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c - int dmic_num; + int dmic_num = 0; + mach_params->dmic_num = dmic_num;
Audio
8cd9956f61c65022209ce6d1e55ed12aea12357d
jaroslav kysela
sound
soc
boards, intel, sof
asoc: intel: add broadwell rt5650 machine driver
add machine driver for broadwell + rt5650.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add broadwell rt5650 machine driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'intel']
['c', 'kconfig', 'makefile']
4
340
0
--- diff --git a/sound/soc/intel/boards/kconfig b/sound/soc/intel/boards/kconfig --- a/sound/soc/intel/boards/kconfig +++ b/sound/soc/intel/boards/kconfig +config snd_soc_intel_bdw_rt5650_mach + tristate "broadwell with rt5650 codec" + depends on i2c + depends on i2c_designware_platform || compile_test + depends on x86_intel_lpss || compile_test + select snd_soc_rt5645 + help + this adds the asoc machine driver for intel broadwell platforms with + the rt5650 codec. + say y if you have such a device. + if unsure select "n". + diff --git a/sound/soc/intel/boards/makefile b/sound/soc/intel/boards/makefile --- a/sound/soc/intel/boards/makefile +++ b/sound/soc/intel/boards/makefile +snd-soc-sst-bdw-rt5650-mach-objs := bdw-rt5650.o +obj-$(config_snd_soc_intel_bdw_rt5650_mach) += snd-soc-sst-bdw-rt5650-mach.o diff --git a/sound/soc/intel/boards/bdw-rt5650.c b/sound/soc/intel/boards/bdw-rt5650.c --- /dev/null +++ b/sound/soc/intel/boards/bdw-rt5650.c +// spdx-license-identifier: gpl-2.0-only +/* + * asoc machine driver for intel broadwell platforms with rt5650 codec + * + * copyright 2019, the chromium os authors. all rights reserved. + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <sound/core.h> +#include <sound/jack.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-acpi.h> + +#include "../common/sst-dsp.h" +#include "../haswell/sst-haswell-ipc.h" + +#include "../../codecs/rt5645.h" + +struct bdw_rt5650_priv { + struct gpio_desc *gpio_hp_en; + struct snd_soc_component *component; +}; + +static const struct snd_soc_dapm_widget bdw_rt5650_widgets[] = { + snd_soc_dapm_hp("headphone", null), + snd_soc_dapm_spk("speaker", null), + snd_soc_dapm_mic("headset mic", null), + snd_soc_dapm_mic("dmic pair1", null), + snd_soc_dapm_mic("dmic pair2", null), +}; + +static const struct snd_soc_dapm_route bdw_rt5650_map[] = { + /* speakers */ + {"speaker", null, "spol"}, + {"speaker", null, "spor"}, + + /* headset jack connectors */ + {"headphone", null, "hpol"}, + {"headphone", null, "hpor"}, + {"in1p", null, "headset mic"}, + {"in1n", null, "headset mic"}, + + /* digital mics + * dmic pair1 are the two dmics connected on the dmicn1 connector. + * dmic pair2 are the two dmics connected on the dmicn2 connector. + * facing the camera, dmic pair1 are on the left side, dmic pair2 + * are on the right side. + */ + {"dmic l1", null, "dmic pair1"}, + {"dmic r1", null, "dmic pair1"}, + {"dmic l2", null, "dmic pair2"}, + {"dmic r2", null, "dmic pair2"}, + + /* codec be connections */ + {"ssp0 codec in", null, "aif1 capture"}, + {"aif1 playback", null, "ssp0 codec out"}, +}; + +static const struct snd_kcontrol_new bdw_rt5650_controls[] = { + soc_dapm_pin_switch("speaker"), + soc_dapm_pin_switch("headphone"), + soc_dapm_pin_switch("headset mic"), + soc_dapm_pin_switch("dmic pair1"), + soc_dapm_pin_switch("dmic pair2"), +}; + + +static struct snd_soc_jack headphone_jack; +static struct snd_soc_jack mic_jack; + +static struct snd_soc_jack_pin headphone_jack_pin = { + .pin = "headphone", + .mask = snd_jack_headphone, +}; + +static struct snd_soc_jack_pin mic_jack_pin = { + .pin = "headset mic", + .mask = snd_jack_microphone, +}; + +static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + sndrv_pcm_hw_param_rate); + struct snd_interval *channels = hw_param_interval(params, + sndrv_pcm_hw_param_channels); + + /* the adsp will covert the fe rate to 48k, max 4-channels */ + rate->min = rate->max = 48000; + channels->min = 2; + channels->max = 4; + + /* set ssp0 to 24 bit */ + snd_mask_set_format(hw_param_mask(params, sndrv_pcm_hw_param_format), + sndrv_pcm_format_s24_le); + + return 0; +} + +static int bdw_rt5650_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + /* workaround: set codec pll to 19.2mhz that pll source is + * from mclk(24mhz) to conform 2.4mhz dmic clock. + */ + ret = snd_soc_dai_set_pll(codec_dai, 0, rt5645_pll1_s_mclk, + 24000000, 19200000); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec pll: %d ", ret); + return ret; + } + + /* the actual mclk freq is 24mhz. the codec is told that mclk is + * 24.576mhz to satisfy the requirement of rl6231_get_clk_info. + * asrc is enabled on ad and da filters to ensure good audio quality. + */ + ret = snd_soc_dai_set_sysclk(codec_dai, rt5645_sclk_s_pll1, 24576000, + snd_soc_clock_in); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec sysclk configuration "); + return ret; + } + + return ret; +} + +static struct snd_soc_ops bdw_rt5650_ops = { + .hw_params = bdw_rt5650_hw_params, +}; + +#if !is_enabled(config_snd_soc_sof_broadwell) +static int bdw_rt5650_rtd_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, drv_name); + struct sst_pdata *pdata = dev_get_platdata(component->dev); + struct sst_hsw *broadwell = pdata->dsp; + int ret; + + /* set adsp ssp port settings + * clock_divider = 4 means bclk = mclk/5 = 24mhz/5 = 4.8mhz + */ + ret = sst_hsw_device_set_config(broadwell, sst_hsw_device_ssp_0, + sst_hsw_device_mclk_freq_24_mhz, + sst_hsw_device_tdm_clock_master, 4); + if (ret < 0) { + dev_err(rtd->dev, "error: failed to set device config "); + return ret; + } + + return 0; +} +#endif + +static int bdw_rt5650_init(struct snd_soc_pcm_runtime *rtd) +{ + struct bdw_rt5650_priv *bdw_rt5650 = + snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_component *component = rtd->codec_dai->component; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + /* enable codec asrc function for stereo dac/stereo1 adc/dmic/i2s1. + * the asrc clock source is clk_i2s1_asrc. + */ + rt5645_sel_asrc_clk_src(component, + rt5645_da_stereo_filter | + rt5645_da_mono_l_filter | + rt5645_da_mono_r_filter | + rt5645_ad_stereo_filter | + rt5645_ad_mono_l_filter | + rt5645_ad_mono_r_filter, + rt5645_clk_sel_i2s1_asrc); + + /* tdm 4 slots 24 bit, set rx & tx bitmask to 4 active slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0xf, 4, 24); + + if (ret < 0) { + dev_err(rtd->dev, "can't set codec tdm slot %d ", ret); + return ret; + } + + /* create and initialize headphone jack */ + if (snd_soc_card_jack_new(rtd->card, "headphone jack", + snd_jack_headphone, &headphone_jack, + &headphone_jack_pin, 1)) { + dev_err(component->dev, "can't create headphone jack "); + } + + /* create and initialize mic jack */ + if (snd_soc_card_jack_new(rtd->card, "mic jack", snd_jack_microphone, + &mic_jack, &mic_jack_pin, 1)) { + dev_err(component->dev, "can't create mic jack "); + } + + rt5645_set_jack_detect(component, &headphone_jack, &mic_jack, null); + + bdw_rt5650->component = component; + + return 0; +} + +/* broadwell digital audio interface glue - connects codec <--> cpu */ +snd_soc_dailink_def(dummy, + dailink_comp_array(comp_dummy())); + +snd_soc_dailink_def(fe, + dailink_comp_array(comp_cpu("system pin"))); + +snd_soc_dailink_def(platform, + dailink_comp_array(comp_platform("haswell-pcm-audio"))); + +snd_soc_dailink_def(be, + dailink_comp_array(comp_codec("i2c-10ec5650:00", "rt5645-aif1"))); + +static struct snd_soc_dai_link bdw_rt5650_dais[] = { + /* front end dai links */ + { + .name = "system pcm", + .stream_name = "system playback", + .dynamic = 1, +#if !is_enabled(config_snd_soc_sof_broadwell) + .init = bdw_rt5650_rtd_init, +#endif + .trigger = { + snd_soc_dpcm_trigger_post, + snd_soc_dpcm_trigger_post + }, + .dpcm_playback = 1, + .dpcm_capture = 1, + snd_soc_dailink_reg(fe, dummy, platform), + }, + + /* back end dai links */ + { + /* ssp0 - codec */ + .name = "codec", + .id = 0, + .no_pcm = 1, + .dai_fmt = snd_soc_daifmt_dsp_b | snd_soc_daifmt_nb_nf | + snd_soc_daifmt_cbs_cfs, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = broadwell_ssp0_fixup, + .ops = &bdw_rt5650_ops, + .dpcm_playback = 1, + .dpcm_capture = 1, + .init = bdw_rt5650_init, + snd_soc_dailink_reg(dummy, be, dummy), + }, +}; + +/* asoc machine driver for broadwell dsp + rt5650 */ +static struct snd_soc_card bdw_rt5650_card = { + .name = "bdw-rt5650", + .owner = this_module, + .dai_link = bdw_rt5650_dais, + .num_links = array_size(bdw_rt5650_dais), + .dapm_widgets = bdw_rt5650_widgets, + .num_dapm_widgets = array_size(bdw_rt5650_widgets), + .dapm_routes = bdw_rt5650_map, + .num_dapm_routes = array_size(bdw_rt5650_map), + .controls = bdw_rt5650_controls, + .num_controls = array_size(bdw_rt5650_controls), + .fully_routed = true, +}; + +static int bdw_rt5650_probe(struct platform_device *pdev) +{ + struct bdw_rt5650_priv *bdw_rt5650; + struct snd_soc_acpi_mach *mach; + int ret; + + bdw_rt5650_card.dev = &pdev->dev; + + /* allocate driver private struct */ + bdw_rt5650 = devm_kzalloc(&pdev->dev, sizeof(struct bdw_rt5650_priv), + gfp_kernel); + if (!bdw_rt5650) + return -enomem; + + /* override plaform name, if required */ + mach = (&pdev->dev)->platform_data; + ret = snd_soc_fixup_dai_links_platform_name(&bdw_rt5650_card, + mach->mach_params.platform); + + if (ret) + return ret; + + snd_soc_card_set_drvdata(&bdw_rt5650_card, bdw_rt5650); + + return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5650_card); +} + +static struct platform_driver bdw_rt5650_audio = { + .probe = bdw_rt5650_probe, + .driver = { + .name = "bdw-rt5650", + .pm = &snd_soc_pm_ops, + }, +}; + +module_platform_driver(bdw_rt5650_audio) + +/* module information */ +module_author("ben zhang <benzh@chromium.org>"); +module_description("intel broadwell rt5650 machine driver"); +module_license("gpl v2"); +module_alias("platform:bdw-rt5650"); diff --git a/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c --- a/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c + { + .id = "10ec5650", + .drv_name = "bdw-rt5650", + .fw_filename = "intel/intcsst2.bin", + .sof_fw_filename = "sof-bdw.ri", + .sof_tplg_filename = "sof-bdw-rt5650.tplg", + },
Audio
5b425814f13f373cf36d58cf1b418e075d45ad86
ben zhang pierre louis bossart pierre louis bossart linux intel com
sound
soc
boards, common, intel
asoc: intel: sof_rt5682: add support for tgl-max98357a-rt5682
this patch adds the driver data and updates quirk info for tgl with max98357a speaker amp and alc5682 headset codec.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support for tgl-max98357a-rt5682
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'intel', 'sof_rt5682']
['c']
1
20
0
--- diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c + if (pdev->id_entry && pdev->id_entry->driver_data) + sof_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data; + +static const struct platform_device_id board_ids[] = { + { + .name = "sof_rt5682", + }, + { + .name = "tgl_max98357a_rt5682", + .driver_data = (kernel_ulong_t)(sof_rt5682_mclk_en | + sof_rt5682_ssp_codec(0) | + sof_speaker_amp_present | + sof_rt5682_ssp_amp(1) | + sof_rt5682_num_hdmidev(4)), + }, + { } +}; + + .id_table = board_ids, +module_alias("platform:tgl_max98357a_rt5682");
Audio
6605f0ca3af3b964635287ec7c9dadc812b78eb0
sathyanarayana nujella
sound
soc
boards, intel
asoc: qcom: sdm845: add support to db845c and lenovo yoga
this patch adds support to lenovo yoga c630 compatible strings and related setup to the sound machine driver.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add support to db845c and lenovo yoga
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'qcom', 'sdm845']
['c']
1
85
1
--- diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c +#define slim_max_tx_ports 16 +#define slim_max_rx_ports 16 +#define wcd934x_default_mclk_rate 9600000 +static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai_link *dai_link = rtd->dai_link; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + u32 rx_ch[slim_max_rx_ports], tx_ch[slim_max_tx_ports]; + u32 rx_ch_cnt = 0, tx_ch_cnt = 0; + int ret = 0, i; + + for (i = 0 ; i < dai_link->num_codecs; i++) { + ret = snd_soc_dai_get_channel_map(rtd->codec_dais[i], + &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch); + + if (ret != 0 && ret != -enotsupp) { + pr_err("failed to get codec chan map, err:%d ", ret); + return ret; + } else if (ret == -enotsupp) { + /* ignore unsupported */ + continue; + } + + if (substream->stream == sndrv_pcm_stream_playback) + ret = snd_soc_dai_set_channel_map(cpu_dai, 0, null, + rx_ch_cnt, rx_ch); + else + ret = snd_soc_dai_set_channel_map(cpu_dai, tx_ch_cnt, + tx_ch, 0, null); + } + + return 0; +} + + case slimbus_0_rx...slimbus_6_tx: + ret = sdm845_slim_snd_hw_params(substream, params); + break; + case quaternary_mi2s_rx: + break; - int rval; + struct snd_soc_dai_link *dai_link = rtd->dai_link; + /* + * codec slimbus configuration + * rx1, rx2, rx3, rx4, rx5, rx6, rx7, rx8, rx9, rx10, rx11, rx12, rx13 + * tx1, tx2, tx3, tx4, tx5, tx6, tx7, tx8, tx9, tx10, tx11, tx12, tx13 + * tx14, tx15, tx16 + */ + unsigned int rx_ch[slim_max_rx_ports] = {144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156}; + unsigned int tx_ch[slim_max_tx_ports] = {128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143}; + int rval, i; + + case slimbus_0_rx...slimbus_6_tx: + for (i = 0 ; i < dai_link->num_codecs; i++) { + rval = snd_soc_dai_set_channel_map(rtd->codec_dais[i], + array_size(tx_ch), + tx_ch, + array_size(rx_ch), + rx_ch); + if (rval != 0 && rval != -enotsupp) + return rval; + + snd_soc_dai_set_sysclk(rtd->codec_dais[i], 0, + wcd934x_default_mclk_rate, + sndrv_pcm_stream_playback); + } + break; + break; + case quaternary_mi2s_rx: + snd_soc_dai_set_sysclk(cpu_dai, + q6afe_lpass_clk_id_quad_mi2s_ibit, + mi2s_bclk_rate, sndrv_pcm_stream_playback); + snd_soc_dai_set_fmt(cpu_dai, snd_soc_daifmt_cbs_cfs); + + + case slimbus_0_rx...slimbus_6_tx: + break; + case slimbus_0_rx...slimbus_6_tx: + case quaternary_mi2s_rx: + break; + { .compatible = "qcom,db845c-sndcard" }, + { .compatible = "lenovo,yoga-c630-sndcard" },
Audio
5caf64c633a3564f70e734868254281b25932fc0
srinivas kandagatla pierre louis bossart pierre louis bossart linux intel com
sound
soc
qcom
asoc: rt1015: add rt1015 amplifier driver
this is initial amplifier driver for rt1015.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add rt1015 amplifier driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'rt1015']
['c', 'kconfig', 'txt', 'makefile', 'h']
5
1,393
0
--- diff --git a/documentation/devicetree/bindings/sound/rt1015.txt b/documentation/devicetree/bindings/sound/rt1015.txt --- /dev/null +++ b/documentation/devicetree/bindings/sound/rt1015.txt +rt1015 mono class d audio amplifier + +this device supports i2c only. + +required properties: + +- compatible : "realtek,rt1015". + +- reg : the i2c address of the device. + + +example: + +rt1015: codec@28 { + compatible = "realtek,rt1015"; + reg = <0x28>; +}; diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_rt1015 if i2c + default y if snd_soc_rt1015=y + default m if snd_soc_rt1015=m +config snd_soc_rt1015 + tristate + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-rt1015-objs := rt1015.o +obj-$(config_snd_soc_rt1015) += snd-soc-rt1015.o diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c --- /dev/null +++ b/sound/soc/codecs/rt1015.c +// spdx-license-identifier: gpl-2.0 +// +// rt1015.c -- rt1015 alsa soc audio amplifier driver +// +// copyright 2019 realtek semiconductor corp. +// +// author: jack yu <jack.yu@realtek.com> +// +// + +#include <linux/fs.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/pm.h> +#include <linux/regmap.h> +#include <linux/i2c.h> +#include <linux/platform_device.h> +#include <linux/firmware.h> +#include <linux/gpio.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/initval.h> +#include <sound/tlv.h> + +#include "rl6231.h" +#include "rt1015.h" + +static const struct reg_default rt1015_reg[] = { + { 0x0000, 0x0000 }, + { 0x0004, 0xa000 }, + { 0x0006, 0x0003 }, + { 0x000a, 0x0802 }, + { 0x000c, 0x0020 }, + { 0x000e, 0x0000 }, + { 0x0010, 0x0000 }, + { 0x0012, 0x0000 }, + { 0x0020, 0x8000 }, + { 0x0022, 0x471b }, + { 0x006a, 0x0000 }, + { 0x006c, 0x4020 }, + { 0x0076, 0x0000 }, + { 0x0078, 0x0000 }, + { 0x007a, 0x0000 }, + { 0x007c, 0x10ec }, + { 0x007d, 0x1015 }, + { 0x00f0, 0x5000 }, + { 0x00f2, 0x0774 }, + { 0x00f3, 0x8400 }, + { 0x00f4, 0x0000 }, + { 0x0100, 0x0028 }, + { 0x0102, 0xff02 }, + { 0x0104, 0x8232 }, + { 0x0106, 0x200c }, + { 0x010c, 0x002f }, + { 0x010e, 0xc000 }, + { 0x0111, 0x0200 }, + { 0x0112, 0x0400 }, + { 0x0114, 0x0022 }, + { 0x0116, 0x0000 }, + { 0x0118, 0x0000 }, + { 0x011a, 0x0123 }, + { 0x011c, 0x4567 }, + { 0x0300, 0xdddd }, + { 0x0302, 0x0000 }, + { 0x0311, 0x9330 }, + { 0x0313, 0x0000 }, + { 0x0314, 0x0000 }, + { 0x031a, 0x00a0 }, + { 0x031c, 0x001f }, + { 0x031d, 0xffff }, + { 0x031e, 0x0000 }, + { 0x031f, 0x0000 }, + { 0x0321, 0x0000 }, + { 0x0322, 0x0000 }, + { 0x0328, 0x0000 }, + { 0x0329, 0x0000 }, + { 0x032a, 0x0000 }, + { 0x032b, 0x0000 }, + { 0x032c, 0x0000 }, + { 0x032d, 0x0000 }, + { 0x032e, 0x030e }, + { 0x0330, 0x0080 }, + { 0x0332, 0x0034 }, + { 0x0334, 0x0000 }, + { 0x0336, 0x0000 }, + { 0x0506, 0x04ff }, + { 0x0508, 0x0030 }, + { 0x050a, 0x0018 }, + { 0x0519, 0x307f }, + { 0x051a, 0xffff }, + { 0x051b, 0x4000 }, + { 0x051d, 0x0000 }, + { 0x051f, 0x0000 }, + { 0x0536, 0x1000 }, + { 0x0538, 0x0000 }, + { 0x053a, 0x0000 }, + { 0x053c, 0x0000 }, + { 0x053d, 0x0000 }, + { 0x053e, 0x0000 }, + { 0x053f, 0x0000 }, + { 0x0540, 0x0000 }, + { 0x0541, 0x0000 }, + { 0x0542, 0x0000 }, + { 0x0543, 0x0000 }, + { 0x0544, 0x0000 }, + { 0x0568, 0x0000 }, + { 0x056a, 0x0000 }, + { 0x1000, 0x0000 }, + { 0x1002, 0x6505 }, + { 0x1006, 0x5515 }, + { 0x1007, 0x003f }, + { 0x1009, 0x770f }, + { 0x100a, 0x01ff }, + { 0x100c, 0x0000 }, + { 0x100d, 0x0003 }, + { 0x1010, 0xa433 }, + { 0x1020, 0x0000 }, + { 0x1200, 0x3d02 }, + { 0x1202, 0x0813 }, + { 0x1204, 0x0211 }, + { 0x1206, 0x0000 }, + { 0x1208, 0x0000 }, + { 0x120a, 0x0000 }, + { 0x120c, 0x0000 }, + { 0x120e, 0x0000 }, + { 0x1210, 0x0000 }, + { 0x1212, 0x0000 }, + { 0x1300, 0x0701 }, + { 0x1302, 0x12f9 }, + { 0x1304, 0x3405 }, + { 0x1305, 0x0844 }, + { 0x1306, 0x1611 }, + { 0x1308, 0x555e }, + { 0x130a, 0x0000 }, + { 0x130c, 0x2400}, + { 0x130e, 0x7700 }, + { 0x130f, 0x0000 }, + { 0x1310, 0x0000 }, + { 0x1312, 0x0000 }, + { 0x1314, 0x0000 }, + { 0x1316, 0x0000 }, + { 0x1318, 0x0000 }, + { 0x131a, 0x0000 }, + { 0x1322, 0x0029 }, + { 0x1323, 0x4a52 }, + { 0x1324, 0x002c }, + { 0x1325, 0x0b02 }, + { 0x1326, 0x002d }, + { 0x1327, 0x6b5a }, + { 0x1328, 0x002e }, + { 0x1329, 0xcbb2 }, + { 0x132a, 0x0030 }, + { 0x132b, 0x2c0b }, + { 0x1330, 0x0031 }, + { 0x1331, 0x8c63 }, + { 0x1332, 0x0032 }, + { 0x1333, 0xecbb }, + { 0x1334, 0x0034 }, + { 0x1335, 0x4d13 }, + { 0x1336, 0x0037 }, + { 0x1337, 0x0dc3 }, + { 0x1338, 0x003d }, + { 0x1339, 0xef7b }, + { 0x133a, 0x0044 }, + { 0x133b, 0xd134 }, + { 0x133c, 0x0047 }, + { 0x133d, 0x91e4 }, + { 0x133e, 0x004d }, + { 0x133f, 0xc370 }, + { 0x1340, 0x0053 }, + { 0x1341, 0xf4fd }, + { 0x1342, 0x0060 }, + { 0x1343, 0x5816 }, + { 0x1344, 0x006c }, + { 0x1345, 0xbb2e }, + { 0x1346, 0x0072 }, + { 0x1347, 0xecbb }, + { 0x1348, 0x0076 }, + { 0x1349, 0x5d97 }, +}; + +static bool rt1015_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case rt1015_reset: + case rt1015_clk_det: + case rt1015_sil_det: + case rt1015_ver_id: + case rt1015_vendor_id: + case rt1015_device_id: + case rt1015_pro_alt: + case rt1015_dac3: + case rt1015_vbat_test_out1: + case rt1015_vbat_test_out2: + case rt1015_vbat_prot_att: + case rt1015_vbat_det_code: + case rt1015_smart_bst_ctrl1: + case rt1015_spk_dc_detect1: + case rt1015_spk_dc_detect4: + case rt1015_spk_dc_detect5: + case rt1015_dc_calib_clsd1: + case rt1015_dc_calib_clsd5: + case rt1015_dc_calib_clsd6: + case rt1015_dc_calib_clsd7: + case rt1015_dc_calib_clsd8: + case rt1015_s_bst_timing_inter1: + return true; + + default: + return false; + } +} + +static bool rt1015_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case rt1015_reset: + case rt1015_clk2: + case rt1015_clk3: + case rt1015_pll1: + case rt1015_pll2: + case rt1015_clk_det: + case rt1015_sil_det: + case rt1015_customer_id: + case rt1015_pcode_fwver: + case rt1015_ver_id: + case rt1015_vendor_id: + case rt1015_device_id: + case rt1015_pad_drv1: + case rt1015_pad_drv2: + case rt1015_gat_boost: + case rt1015_pro_alt: + case rt1015_man_i2c: + case rt1015_dac1: + case rt1015_dac2: + case rt1015_dac3: + case rt1015_adc1: + case rt1015_adc2: + case rt1015_tdm_master: + case rt1015_tdm_tcon: + case rt1015_tdm1_1: + case rt1015_tdm1_2: + case rt1015_tdm1_3: + case rt1015_tdm1_4: + case rt1015_tdm1_5: + case rt1015_mixer1: + case rt1015_mixer2: + case rt1015_ana_protect1: + case rt1015_ana_ctrl_seq1: + case rt1015_ana_ctrl_seq2: + case rt1015_vbat_det_deb: + case rt1015_vbat_volt_det1: + case rt1015_vbat_volt_det2: + case rt1015_vbat_test_out1: + case rt1015_vbat_test_out2: + case rt1015_vbat_prot_att: + case rt1015_vbat_det_code: + case rt1015_pwr1: + case rt1015_pwr4: + case rt1015_pwr5: + case rt1015_pwr6: + case rt1015_pwr7: + case rt1015_pwr8: + case rt1015_pwr9: + case rt1015_classd_seq: + case rt1015_smart_bst_ctrl1: + case rt1015_smart_bst_ctrl2: + case rt1015_ana_ctrl1: + case rt1015_ana_ctrl2: + case rt1015_spk_vol: + case rt1015_short_dettop1: + case rt1015_short_dettop2: + case rt1015_spk_dc_detect1: + case rt1015_spk_dc_detect2: + case rt1015_spk_dc_detect3: + case rt1015_spk_dc_detect4: + case rt1015_spk_dc_detect5: + case rt1015_bat_rpo_step1: + case rt1015_bat_rpo_step2: + case rt1015_bat_rpo_step3: + case rt1015_bat_rpo_step4: + case rt1015_bat_rpo_step5: + case rt1015_bat_rpo_step6: + case rt1015_bat_rpo_step7: + case rt1015_bat_rpo_step8: + case rt1015_bat_rpo_step9: + case rt1015_bat_rpo_step10: + case rt1015_bat_rpo_step11: + case rt1015_bat_rpo_step12: + case rt1015_spread_spec1: + case rt1015_spread_spec2: + case rt1015_pad_status: + case rt1015_pads_pulling_ctrl1: + case rt1015_pads_driving: + case rt1015_sys_rst1: + case rt1015_sys_rst2: + case rt1015_sys_gating1: + case rt1015_test_mode1: + case rt1015_test_mode2: + case rt1015_timing_ctrl1: + case rt1015_pll_int: + case rt1015_test_out1: + case rt1015_dc_calib_clsd1: + case rt1015_dc_calib_clsd2: + case rt1015_dc_calib_clsd3: + case rt1015_dc_calib_clsd4: + case rt1015_dc_calib_clsd5: + case rt1015_dc_calib_clsd6: + case rt1015_dc_calib_clsd7: + case rt1015_dc_calib_clsd8: + case rt1015_dc_calib_clsd9: + case rt1015_dc_calib_clsd10: + case rt1015_clsd_internal1: + case rt1015_clsd_internal2: + case rt1015_clsd_internal3: + case rt1015_clsd_internal4: + case rt1015_clsd_internal5: + case rt1015_clsd_internal6: + case rt1015_clsd_internal7: + case rt1015_clsd_internal8: + case rt1015_clsd_internal9: + case rt1015_clsd_ocp_ctrl: + case rt1015_vref_lv: + case rt1015_mbias1: + case rt1015_mbias2: + case rt1015_mbias3: + case rt1015_mbias4: + case rt1015_vref_lv1: + case rt1015_s_bst_timing_inter1: + case rt1015_s_bst_timing_inter2: + case rt1015_s_bst_timing_inter3: + case rt1015_s_bst_timing_inter4: + case rt1015_s_bst_timing_inter5: + case rt1015_s_bst_timing_inter6: + case rt1015_s_bst_timing_inter7: + case rt1015_s_bst_timing_inter8: + case rt1015_s_bst_timing_inter9: + case rt1015_s_bst_timing_inter10: + case rt1015_s_bst_timing_inter11: + case rt1015_s_bst_timing_inter12: + case rt1015_s_bst_timing_inter13: + case rt1015_s_bst_timing_inter14: + case rt1015_s_bst_timing_inter15: + case rt1015_s_bst_timing_inter16: + case rt1015_s_bst_timing_inter17: + case rt1015_s_bst_timing_inter18: + case rt1015_s_bst_timing_inter19: + case rt1015_s_bst_timing_inter20: + case rt1015_s_bst_timing_inter21: + case rt1015_s_bst_timing_inter22: + case rt1015_s_bst_timing_inter23: + case rt1015_s_bst_timing_inter24: + case rt1015_s_bst_timing_inter25: + case rt1015_s_bst_timing_inter26: + case rt1015_s_bst_timing_inter27: + case rt1015_s_bst_timing_inter28: + case rt1015_s_bst_timing_inter29: + case rt1015_s_bst_timing_inter30: + case rt1015_s_bst_timing_inter31: + case rt1015_s_bst_timing_inter32: + case rt1015_s_bst_timing_inter33: + case rt1015_s_bst_timing_inter34: + case rt1015_s_bst_timing_inter35: + case rt1015_s_bst_timing_inter36: + return true; + + default: + return false; + } +} + +static const declare_tlv_db_scale(dac_vol_tlv, -9525, 75, 0); + +static const char * const rt1015_din_source_select[] = { + "left", + "right", + "left + right average", +}; + +static soc_enum_single_decl(rt1015_mono_lr_sel, rt1015_pad_drv2, 4, + rt1015_din_source_select); + +static const char * const rt1015_boost_mode[] = { + "bypass", "adaptive", "fixed adaptive" +}; + +static const soc_enum_single_decl(rt1015_boost_mode_enum, 0, 0, + rt1015_boost_mode); + +static int rt1015_boost_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = rt1015->boost_mode; + + return 0; +} + +static int rt1015_boost_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + rt1015->boost_mode = ucontrol->value.integer.value[0]; + + switch (rt1015->boost_mode) { + case bypass: + snd_soc_component_update_bits(component, + rt1015_smart_bst_ctrl1, rt1015_abst_auto_en_mask | + rt1015_abst_fix_tgt_mask | rt1015_bypass_swr_reg_mask, + rt1015_abst_reg_mode | rt1015_abst_fix_tgt_dis | + rt1015_bypass_swrreg_bypass); + break; + case adaptive: + snd_soc_component_update_bits(component, + rt1015_smart_bst_ctrl1, rt1015_abst_auto_en_mask | + rt1015_abst_fix_tgt_mask | rt1015_bypass_swr_reg_mask, + rt1015_abst_auto_mode | rt1015_abst_fix_tgt_dis | + rt1015_bypass_swrreg_pass); + break; + case fixed_adaptive: + snd_soc_component_update_bits(component, + rt1015_smart_bst_ctrl1, rt1015_abst_auto_en_mask | + rt1015_abst_fix_tgt_mask | rt1015_bypass_swr_reg_mask, + rt1015_abst_auto_mode | rt1015_abst_fix_tgt_en | + rt1015_bypass_swrreg_pass); + break; + default: + dev_err(component->dev, "unknown boost control. "); + } + + return 0; +} + +static int rt5518_bypass_boost_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = rt1015->bypass_boost; + + return 0; +} + +static int rt5518_bypass_boost_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + if (!rt1015->dac_is_used) { + rt1015->bypass_boost = ucontrol->value.integer.value[0]; + if (rt1015->bypass_boost == 1) { + snd_soc_component_write(component, + rt1015_pwr4, 0x00b2); + snd_soc_component_write(component, + rt1015_clsd_internal8, 0x2008); + snd_soc_component_write(component, + rt1015_clsd_internal9, 0x0140); + snd_soc_component_write(component, + rt1015_gat_boost, 0x00fe); + snd_soc_component_write(component, + rt1015_pwr_state_ctrl, 0x000d); + msleep(500); + snd_soc_component_write(component, + rt1015_pwr_state_ctrl, 0x000e); + } + } else + dev_err(component->dev, "dac is being used! "); + + return 0; +} + +static const struct snd_kcontrol_new rt1015_snd_controls[] = { + soc_single_tlv("dac playback volume", rt1015_dac1, rt1015_dac_vol_sft, + 127, 0, dac_vol_tlv), + soc_double("dac playback switch", rt1015_dac3, + rt1015_da_mute_sft, rt1015_dvol_mute_flag_sft, 1, 1), + soc_enum_ext("boost mode", rt1015_boost_mode_enum, + rt1015_boost_mode_get, rt1015_boost_mode_put), + soc_enum("mono lr select", rt1015_mono_lr_sel), + soc_single_ext("bypass boost", snd_soc_nopm, 0, 1, 0, + rt5518_bypass_boost_get, rt5518_bypass_boost_put), +}; + +static int rt1015_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, + struct snd_soc_dapm_widget *sink) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(source->dapm); + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + if (rt1015->sysclk_src == rt1015_sclk_s_pll) + return 1; + else + return 0; +} + +static int r1015_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_pre_pmu: + rt1015->dac_is_used = 1; + if (rt1015->bypass_boost == 0) { + snd_soc_component_write(component, + rt1015_sys_rst1, 0x05f7); + snd_soc_component_write(component, + rt1015_gat_boost, 0xacfe); + snd_soc_component_write(component, + rt1015_pwr9, 0xaa00); + snd_soc_component_write(component, + rt1015_gat_boost, 0xecfe); + } else { + snd_soc_component_write(component, + rt1015_sys_rst1, 0x05f7); + snd_soc_component_write(component, + rt1015_pwr_state_ctrl, 0x026e); + } + break; + + case snd_soc_dapm_post_pmd: + if (rt1015->bypass_boost == 0) { + snd_soc_component_write(component, + rt1015_pwr9, 0xa800); + snd_soc_component_write(component, + rt1015_sys_rst1, 0x05f5); + } else { + snd_soc_component_write(component, + rt1015_pwr_state_ctrl, 0x0268); + snd_soc_component_write(component, + rt1015_sys_rst1, 0x05f5); + } + rt1015->dac_is_used = 0; + break; + + default: + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget rt1015_dapm_widgets[] = { + snd_soc_dapm_supply("ldo2", rt1015_pwr1, rt1015_pwr_ldo2_bit, 0, + null, 0), + snd_soc_dapm_supply("int rc clk", rt1015_pwr1, rt1015_pwr_intclk_bit, + 0, null, 0), + snd_soc_dapm_supply("isense", rt1015_pwr1, rt1015_pwr_isense_bit, 0, + null, 0), + snd_soc_dapm_supply("vsense", rt1015_pwr1, rt1015_pwr_vsense_bit, 0, + null, 0), + snd_soc_dapm_supply("pll", rt1015_pwr1, rt1015_pwr_pll_bit, 0, + null, 0), + snd_soc_dapm_supply("bg1 bg2", rt1015_pwr1, rt1015_pwr_bg_1_2_bit, 0, + null, 0), + snd_soc_dapm_supply("mbias bg", rt1015_pwr1, rt1015_pwr_mbias_bg_bit, 0, + null, 0), + snd_soc_dapm_supply("vbat", rt1015_pwr1, rt1015_pwr_vbat_bit, 0, null, + 0), + snd_soc_dapm_supply("mbias", rt1015_pwr1, rt1015_pwr_mbias_bit, 0, + null, 0), + snd_soc_dapm_supply("adcv", rt1015_pwr1, rt1015_pwr_adcv_bit, 0, null, + 0), + snd_soc_dapm_supply("mixerv", rt1015_pwr1, rt1015_pwr_mixerv_bit, 0, + null, 0), + snd_soc_dapm_supply("sumv", rt1015_pwr1, rt1015_pwr_sumv_bit, 0, null, + 0), + snd_soc_dapm_supply("vreflv", rt1015_pwr1, rt1015_pwr_vreflv_bit, 0, + null, 0), + + snd_soc_dapm_aif_in("aifrx", "aif playback", 0, snd_soc_nopm, 0, 0), + snd_soc_dapm_dac_e("dac", null, rt1015_pwr1, rt1015_pwr_dac_bit, 0, + r1015_dac_event, snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd), + + snd_soc_dapm_output("spo"), +}; + +static const struct snd_soc_dapm_route rt1015_dapm_routes[] = { + { "dac", null, "aifrx" }, + { "dac", null, "ldo2" }, + { "dac", null, "pll", rt1015_is_sys_clk_from_pll}, + { "dac", null, "int rc clk" }, + { "dac", null, "isense" }, + { "dac", null, "vsense" }, + { "dac", null, "bg1 bg2" }, + { "dac", null, "mbias bg" }, + { "dac", null, "vbat" }, + { "dac", null, "mbias" }, + { "dac", null, "adcv" }, + { "dac", null, "mixerv" }, + { "dac", null, "sumv" }, + { "dac", null, "vreflv" }, + { "spo", null, "dac" }, +}; + +static int rt1015_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + int pre_div, bclk_ms, frame_size; + unsigned int val_len = 0; + + rt1015->lrck = params_rate(params); + pre_div = rl6231_get_clk_info(rt1015->sysclk, rt1015->lrck); + if (pre_div < 0) { + dev_err(component->dev, "unsupported clock rate "); + return -einval; + } + + frame_size = snd_soc_params_to_frame_size(params); + if (frame_size < 0) { + dev_err(component->dev, "unsupported frame size: %d ", + frame_size); + return -einval; + } + + bclk_ms = frame_size > 32; + rt1015->bclk = rt1015->lrck * (32 << bclk_ms); + + dev_dbg(component->dev, "bclk_ms is %d and pre_div is %d for iis %d ", + bclk_ms, pre_div, dai->id); + + dev_dbg(component->dev, "lrck is %dhz and pre_div is %d for iis %d ", + rt1015->lrck, pre_div, dai->id); + + switch (params_width(params)) { + case 16: + break; + case 20: + val_len = rt1015_i2s_dl_20; + break; + case 24: + val_len = rt1015_i2s_dl_24; + break; + case 8: + val_len = rt1015_i2s_dl_8; + break; + default: + return -einval; + } + + snd_soc_component_update_bits(component, rt1015_tdm_master, + rt1015_i2s_dl_mask, val_len); + snd_soc_component_update_bits(component, rt1015_clk2, + rt1015_fs_pd_mask, pre_div); + + return 0; +} + +static int rt1015_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct snd_soc_component *component = dai->component; + unsigned int reg_val = 0, reg_val2 = 0; + + switch (fmt & snd_soc_daifmt_master_mask) { + case snd_soc_daifmt_cbm_cfm: + reg_val |= rt1015_tcon_tdm_ms_m; + break; + case snd_soc_daifmt_cbs_cfs: + reg_val |= rt1015_tcon_tdm_ms_s; + break; + default: + return -einval; + } + + switch (fmt & snd_soc_daifmt_inv_mask) { + case snd_soc_daifmt_nb_nf: + break; + case snd_soc_daifmt_ib_nf: + reg_val2 |= rt1015_tdm_inv_bclk; + break; + default: + return -einval; + } + + switch (fmt & snd_soc_daifmt_format_mask) { + case snd_soc_daifmt_i2s: + break; + + case snd_soc_daifmt_left_j: + reg_val |= rt1015_i2s_m_df_left; + break; + + case snd_soc_daifmt_dsp_a: + reg_val |= rt1015_i2s_m_df_pcm_a; + break; + + case snd_soc_daifmt_dsp_b: + reg_val |= rt1015_i2s_m_df_pcm_b; + break; + + default: + return -einval; + } + + snd_soc_component_update_bits(component, rt1015_tdm_master, + rt1015_tcon_tdm_ms_mask | rt1015_i2s_m_df_mask, + reg_val); + snd_soc_component_update_bits(component, rt1015_tdm1_1, + rt1015_tdm_inv_bclk_mask, reg_val2); + + return 0; +} + +static int rt1015_set_component_sysclk(struct snd_soc_component *component, + int clk_id, int source, unsigned int freq, int dir) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + unsigned int reg_val = 0; + + if (freq == rt1015->sysclk && clk_id == rt1015->sysclk_src) + return 0; + + switch (clk_id) { + case rt1015_sclk_s_mclk: + reg_val |= rt1015_clk_sys_pre_sel_mclk; + break; + + case rt1015_sclk_s_pll: + reg_val |= rt1015_clk_sys_pre_sel_pll; + break; + + default: + dev_err(component->dev, "invalid clock id (%d) ", clk_id); + return -einval; + } + + rt1015->sysclk = freq; + rt1015->sysclk_src = clk_id; + + dev_dbg(component->dev, "sysclk is %dhz and clock id is %d ", + freq, clk_id); + + snd_soc_component_update_bits(component, rt1015_clk2, + rt1015_clk_sys_pre_sel_mask, reg_val); + + return 0; +} + +static int rt1015_set_component_pll(struct snd_soc_component *component, + int pll_id, int source, unsigned int freq_in, + unsigned int freq_out) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + struct rl6231_pll_code pll_code; + int ret; + + if (!freq_in || !freq_out) { + dev_dbg(component->dev, "pll disabled "); + + rt1015->pll_in = 0; + rt1015->pll_out = 0; + + return 0; + } + + if (source == rt1015->pll_src && freq_in == rt1015->pll_in && + freq_out == rt1015->pll_out) + return 0; + + switch (source) { + case rt1015_pll_s_mclk: + snd_soc_component_update_bits(component, rt1015_clk2, + rt1015_pll_sel_mask, rt1015_pll_sel_pll_src2); + break; + + case rt1015_pll_s_bclk: + snd_soc_component_update_bits(component, rt1015_clk2, + rt1015_pll_sel_mask, rt1015_pll_sel_bclk); + break; + + default: + dev_err(component->dev, "unknown pll source %d ", source); + return -einval; + } + + ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); + if (ret < 0) { + dev_err(component->dev, "unsupport input clock %d ", freq_in); + return ret; + } + + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d ", + pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), + pll_code.n_code, pll_code.k_code); + + snd_soc_component_write(component, rt1015_pll1, + (pll_code.m_bp ? 0 : pll_code.m_code) << rt1015_pll_m_sft | + pll_code.m_bp << rt1015_pll_m_bp_sft | pll_code.n_code); + snd_soc_component_write(component, rt1015_pll2, + pll_code.k_code); + + rt1015->pll_in = freq_in; + rt1015->pll_out = freq_out; + rt1015->pll_src = source; + + return 0; +} + +static int rt1015_probe(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + rt1015->component = component; + snd_soc_component_write(component, rt1015_bat_rpo_step1, 0x061c); + + return 0; +} + +static void rt1015_remove(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + regmap_write(rt1015->regmap, rt1015_reset, 0); +} + +#define rt1015_stereo_rates sndrv_pcm_rate_8000_192000 +#define rt1015_formats (sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s20_3le | \ + sndrv_pcm_fmtbit_s24_le | sndrv_pcm_fmtbit_s8) + +struct snd_soc_dai_ops rt1015_aif_dai_ops = { + .hw_params = rt1015_hw_params, + .set_fmt = rt1015_set_dai_fmt, +}; + +struct snd_soc_dai_driver rt1015_dai[] = { + { + .name = "rt1015-aif", + .id = 0, + .playback = { + .stream_name = "aif playback", + .channels_min = 1, + .channels_max = 4, + .rates = rt1015_stereo_rates, + .formats = rt1015_formats, + }, + } +}; + +#ifdef config_pm +static int rt1015_suspend(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + regcache_cache_only(rt1015->regmap, true); + regcache_mark_dirty(rt1015->regmap); + + return 0; +} + +static int rt1015_resume(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + regcache_cache_only(rt1015->regmap, false); + regcache_sync(rt1015->regmap); + return 0; +} +#else +#define rt1015_suspend null +#define rt1015_resume null +#endif + +static const struct snd_soc_component_driver soc_component_dev_rt1015 = { + .probe = rt1015_probe, + .remove = rt1015_remove, + .suspend = rt1015_suspend, + .resume = rt1015_resume, + .controls = rt1015_snd_controls, + .num_controls = array_size(rt1015_snd_controls), + .dapm_widgets = rt1015_dapm_widgets, + .num_dapm_widgets = array_size(rt1015_dapm_widgets), + .dapm_routes = rt1015_dapm_routes, + .num_dapm_routes = array_size(rt1015_dapm_routes), + .set_sysclk = rt1015_set_component_sysclk, + .set_pll = rt1015_set_component_pll, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + +static const struct regmap_config rt1015_regmap = { + .reg_bits = 16, + .val_bits = 16, + .max_register = rt1015_s_bst_timing_inter36, + .volatile_reg = rt1015_volatile_register, + .readable_reg = rt1015_readable_register, + .cache_type = regcache_rbtree, + .reg_defaults = rt1015_reg, + .num_reg_defaults = array_size(rt1015_reg), +}; + +static const struct i2c_device_id rt1015_i2c_id[] = { + { "rt1015", 0 }, + { } +}; +module_device_table(i2c, rt1015_i2c_id); + +#if defined(config_of) +static const struct of_device_id rt1015_of_match[] = { + { .compatible = "realtek,rt1015", }, + {}, +}; +module_device_table(of, rt1015_of_match); +#endif + +#ifdef config_acpi +static struct acpi_device_id rt1015_acpi_match[] = { + {"10ec1015", 0,}, + {}, +}; +module_device_table(acpi, rt1015_acpi_match); +#endif + +static int rt1015_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct rt1015_priv *rt1015; + int ret; + unsigned int val; + + rt1015 = devm_kzalloc(&i2c->dev, sizeof(struct rt1015_priv), + gfp_kernel); + if (rt1015 == null) + return -enomem; + + i2c_set_clientdata(i2c, rt1015); + + rt1015->regmap = devm_regmap_init_i2c(i2c, &rt1015_regmap); + if (is_err(rt1015->regmap)) { + ret = ptr_err(rt1015->regmap); + dev_err(&i2c->dev, "failed to allocate register map: %d ", + ret); + return ret; + } + + regmap_read(rt1015->regmap, rt1015_device_id, &val); + if ((val != rt1015_device_id_val) && (val != rt1015_device_id_val2)) { + dev_err(&i2c->dev, + "device with id register %x is not rt1015 ", val); + return -enodev; + } + + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt1015, + rt1015_dai, array_size(rt1015_dai)); +} + +static void rt1015_i2c_shutdown(struct i2c_client *client) +{ + struct rt1015_priv *rt1015 = i2c_get_clientdata(client); + + regmap_write(rt1015->regmap, rt1015_reset, 0); +} + +static struct i2c_driver rt1015_i2c_driver = { + .driver = { + .name = "rt1015", + .of_match_table = of_match_ptr(rt1015_of_match), + .acpi_match_table = acpi_ptr(rt1015_acpi_match), + }, + .probe = rt1015_i2c_probe, + .shutdown = rt1015_i2c_shutdown, + .id_table = rt1015_i2c_id, +}; +module_i2c_driver(rt1015_i2c_driver); + +module_description("asoc rt1015 driver"); +module_author("jack yu <jack.yu@realtek.com>"); +module_license("gpl v2"); diff --git a/sound/soc/codecs/rt1015.h b/sound/soc/codecs/rt1015.h --- /dev/null +++ b/sound/soc/codecs/rt1015.h +// spdx-license-identifier: gpl-2.0 +// +// rt1015.h -- rt1015 alsa soc audio amplifier driver +// +// copyright 2019 realtek semiconductor corp. +// author: jack yu <jack.yu@realtek.com> +// +// this program is free software; you can redistribute it and/or modify +// it under the terms of the gnu general public license version 2 as +// published by the free software foundation. +// + +#ifndef __rt1015_h__ +#define __rt1015_h__ + +#define rt1015_device_id_val 0x1011 +#define rt1015_device_id_val2 0x1015 + +#define rt1015_reset 0x0000 +#define rt1015_clk2 0x0004 +#define rt1015_clk3 0x0006 +#define rt1015_pll1 0x000a +#define rt1015_pll2 0x000c +#define rt1015_clk_det 0x0020 +#define rt1015_sil_det 0x0022 +#define rt1015_customer_id 0x0076 +#define rt1015_pcode_fwver 0x0078 +#define rt1015_ver_id 0x007a +#define rt1015_vendor_id 0x007c +#define rt1015_device_id 0x007d +#define rt1015_pad_drv1 0x00f0 +#define rt1015_pad_drv2 0x00f2 +#define rt1015_gat_boost 0x00f3 +#define rt1015_pro_alt 0x00f4 +#define rt1015_man_i2c 0x0100 +#define rt1015_dac1 0x0102 +#define rt1015_dac2 0x0104 +#define rt1015_dac3 0x0106 +#define rt1015_adc1 0x010c +#define rt1015_adc2 0x010e +#define rt1015_tdm_master 0x0111 +#define rt1015_tdm_tcon 0x0112 +#define rt1015_tdm1_1 0x0114 +#define rt1015_tdm1_2 0x0116 +#define rt1015_tdm1_3 0x0118 +#define rt1015_tdm1_4 0x011a +#define rt1015_tdm1_5 0x011c +#define rt1015_mixer1 0x0300 +#define rt1015_mixer2 0x0302 +#define rt1015_ana_protect1 0x0311 +#define rt1015_ana_ctrl_seq1 0x0313 +#define rt1015_ana_ctrl_seq2 0x0314 +#define rt1015_vbat_det_deb 0x031a +#define rt1015_vbat_volt_det1 0x031c +#define rt1015_vbat_volt_det2 0x031d +#define rt1015_vbat_test_out1 0x031e +#define rt1015_vbat_test_out2 0x031f +#define rt1015_vbat_prot_att 0x0320 +#define rt1015_vbat_det_code 0x0321 +#define rt1015_pwr1 0x0322 +#define rt1015_pwr4 0x0328 +#define rt1015_pwr5 0x0329 +#define rt1015_pwr6 0x032a +#define rt1015_pwr7 0x032b +#define rt1015_pwr8 0x032c +#define rt1015_pwr9 0x032d +#define rt1015_classd_seq 0x032e +#define rt1015_smart_bst_ctrl1 0x0330 +#define rt1015_smart_bst_ctrl2 0x0332 +#define rt1015_ana_ctrl1 0x0334 +#define rt1015_ana_ctrl2 0x0336 +#define rt1015_pwr_state_ctrl 0x0338 +#define rt1015_spk_vol 0x0506 +#define rt1015_short_dettop1 0x0508 +#define rt1015_short_dettop2 0x050a +#define rt1015_spk_dc_detect1 0x0519 +#define rt1015_spk_dc_detect2 0x051a +#define rt1015_spk_dc_detect3 0x051b +#define rt1015_spk_dc_detect4 0x051d +#define rt1015_spk_dc_detect5 0x051f +#define rt1015_bat_rpo_step1 0x0536 +#define rt1015_bat_rpo_step2 0x0538 +#define rt1015_bat_rpo_step3 0x053a +#define rt1015_bat_rpo_step4 0x053c +#define rt1015_bat_rpo_step5 0x053d +#define rt1015_bat_rpo_step6 0x053e +#define rt1015_bat_rpo_step7 0x053f +#define rt1015_bat_rpo_step8 0x0540 +#define rt1015_bat_rpo_step9 0x0541 +#define rt1015_bat_rpo_step10 0x0542 +#define rt1015_bat_rpo_step11 0x0543 +#define rt1015_bat_rpo_step12 0x0544 +#define rt1015_spread_spec1 0x0568 +#define rt1015_spread_spec2 0x056a +#define rt1015_pad_status 0x1000 +#define rt1015_pads_pulling_ctrl1 0x1002 +#define rt1015_pads_driving 0x1006 +#define rt1015_sys_rst1 0x1007 +#define rt1015_sys_rst2 0x1009 +#define rt1015_sys_gating1 0x100a +#define rt1015_test_mode1 0x100c +#define rt1015_test_mode2 0x100d +#define rt1015_timing_ctrl1 0x100e +#define rt1015_pll_int 0x1010 +#define rt1015_test_out1 0x1020 +#define rt1015_dc_calib_clsd1 0x1200 +#define rt1015_dc_calib_clsd2 0x1202 +#define rt1015_dc_calib_clsd3 0x1204 +#define rt1015_dc_calib_clsd4 0x1206 +#define rt1015_dc_calib_clsd5 0x1208 +#define rt1015_dc_calib_clsd6 0x120a +#define rt1015_dc_calib_clsd7 0x120c +#define rt1015_dc_calib_clsd8 0x120e +#define rt1015_dc_calib_clsd9 0x1210 +#define rt1015_dc_calib_clsd10 0x1212 +#define rt1015_clsd_internal1 0x1300 +#define rt1015_clsd_internal2 0x1302 +#define rt1015_clsd_internal3 0x1304 +#define rt1015_clsd_internal4 0x1305 +#define rt1015_clsd_internal5 0x1306 +#define rt1015_clsd_internal6 0x1308 +#define rt1015_clsd_internal7 0x130a +#define rt1015_clsd_internal8 0x130c +#define rt1015_clsd_internal9 0x130e +#define rt1015_clsd_ocp_ctrl 0x130f +#define rt1015_vref_lv 0x1310 +#define rt1015_mbias1 0x1312 +#define rt1015_mbias2 0x1314 +#define rt1015_mbias3 0x1316 +#define rt1015_mbias4 0x1318 +#define rt1015_vref_lv1 0x131a +#define rt1015_s_bst_timing_inter1 0x1322 +#define rt1015_s_bst_timing_inter2 0x1323 +#define rt1015_s_bst_timing_inter3 0x1324 +#define rt1015_s_bst_timing_inter4 0x1325 +#define rt1015_s_bst_timing_inter5 0x1326 +#define rt1015_s_bst_timing_inter6 0x1327 +#define rt1015_s_bst_timing_inter7 0x1328 +#define rt1015_s_bst_timing_inter8 0x1329 +#define rt1015_s_bst_timing_inter9 0x132a +#define rt1015_s_bst_timing_inter10 0x132b +#define rt1015_s_bst_timing_inter11 0x1330 +#define rt1015_s_bst_timing_inter12 0x1331 +#define rt1015_s_bst_timing_inter13 0x1332 +#define rt1015_s_bst_timing_inter14 0x1333 +#define rt1015_s_bst_timing_inter15 0x1334 +#define rt1015_s_bst_timing_inter16 0x1335 +#define rt1015_s_bst_timing_inter17 0x1336 +#define rt1015_s_bst_timing_inter18 0x1337 +#define rt1015_s_bst_timing_inter19 0x1338 +#define rt1015_s_bst_timing_inter20 0x1339 +#define rt1015_s_bst_timing_inter21 0x133a +#define rt1015_s_bst_timing_inter22 0x133b +#define rt1015_s_bst_timing_inter23 0x133c +#define rt1015_s_bst_timing_inter24 0x133d +#define rt1015_s_bst_timing_inter25 0x133e +#define rt1015_s_bst_timing_inter26 0x133f +#define rt1015_s_bst_timing_inter27 0x1340 +#define rt1015_s_bst_timing_inter28 0x1341 +#define rt1015_s_bst_timing_inter29 0x1342 +#define rt1015_s_bst_timing_inter30 0x1343 +#define rt1015_s_bst_timing_inter31 0x1344 +#define rt1015_s_bst_timing_inter32 0x1345 +#define rt1015_s_bst_timing_inter33 0x1346 +#define rt1015_s_bst_timing_inter34 0x1347 +#define rt1015_s_bst_timing_inter35 0x1348 +#define rt1015_s_bst_timing_inter36 0x1349 + +/* 0x0004 */ +#define rt1015_clk_sys_pre_sel_mask (0x3 << 14) +#define rt1015_clk_sys_pre_sel_sft 14 +#define rt1015_clk_sys_pre_sel_mclk (0x0 << 14) +#define rt1015_clk_sys_pre_sel_pll (0x2 << 14) +#define rt1015_pll_sel_mask (0x1 << 13) +#define rt1015_pll_sel_sft 13 +#define rt1015_pll_sel_pll_src2 (0x0 << 13) +#define rt1015_pll_sel_bclk (0x1 << 13) +#define rt1015_fs_pd_mask (0x7 << 4) +#define rt1015_fs_pd_sft 4 + +/* 0x000a */ +#define rt1015_pll_m_max 0xf +#define rt1015_pll_m_mask (rt1015_pll_m_max << 12) +#define rt1015_pll_m_sft 12 +#define rt1015_pll_m_bp (0x1 << 11) +#define rt1015_pll_m_bp_sft 11 +#define rt1015_pll_n_max 0x1ff +#define rt1015_pll_n_mask (rt1015_pll_n_max << 0) +#define rt1015_pll_n_sft 0 + +/* 0x000c */ +#define rt1015_pll_bpk_mask (0x1 << 5) +#define rt1015_pll_bpk (0x0 << 5) +#define rt1015_pll_k_max 0x1f +#define rt1015_pll_k_mask (rt1015_pll_k_max) +#define rt1015_pll_k_sft 0 + +/* 0x007a */ +#define rt1015_id_mask 0xff +#define rt1015_id_vera 0x0 +#define rt1015_id_verb 0x1 + +/* 0x0102 */ +#define rt1015_dac_vol_mask (0x7f << 9) +#define rt1015_dac_vol_sft 9 + +/* 0x0104 */ +#define rt1015_dac_clk (0x1 << 13) +#define rt1015_dac_clk_bit 13 + +/* 0x0106 */ +#define rt1015_dac_mute_mask (0x1 << 15) +#define rt1015_da_mute_sft 15 +#define rt1015_dvol_mute_flag_sft 12 + +/* 0x0111 */ +#define rt1015_tcon_tdm_ms_mask (0x1 << 14) +#define rt1015_tcon_tdm_ms_sft 14 +#define rt1015_tcon_tdm_ms_s (0x0 << 14) +#define rt1015_tcon_tdm_ms_m (0x1 << 14) +#define rt1015_i2s_dl_mask (0x7 << 8) +#define rt1015_i2s_dl_sft 8 +#define rt1015_i2s_dl_16 (0x0 << 8) +#define rt1015_i2s_dl_20 (0x1 << 8) +#define rt1015_i2s_dl_24 (0x2 << 8) +#define rt1015_i2s_dl_8 (0x3 << 8) +#define rt1015_i2s_m_df_mask (0x7 << 0) +#define rt1015_i2s_m_df_sft 0 +#define rt1015_i2s_m_df_i2s (0x0) +#define rt1015_i2s_m_df_left (0x1) +#define rt1015_i2s_m_df_pcm_a (0x2) +#define rt1015_i2s_m_df_pcm_b (0x3) +#define rt1015_i2s_m_df_pcm_a_n (0x6) +#define rt1015_i2s_m_df_pcm_b_n (0x7) + +/* tdm_tcon setting (0x0112) */ +#define rt1015_i2s_tcon_df_mask (0x7 << 13) +#define rt1015_i2s_tcon_df_sft 13 +#define rt1015_i2s_tcon_df_i2s (0x0 << 13) +#define rt1015_i2s_tcon_df_left (0x1 << 13) +#define rt1015_i2s_tcon_df_pcm_a (0x2 << 13) +#define rt1015_i2s_tcon_df_pcm_b (0x3 << 13) +#define rt1015_i2s_tcon_df_pcm_a_n (0x6 << 13) +#define rt1015_i2s_tcon_df_pcm_b_n (0x7 << 13) +#define rt1015_tcon_bclk_sel_mask (0x3 << 10) +#define rt1015_tcon_bclk_sel_sft 10 +#define rt1015_tcon_bclk_sel_32fs (0x0 << 10) +#define rt1015_tcon_bclk_sel_64fs (0x1 << 10) +#define rt1015_tcon_bclk_sel_128fs (0x2 << 10) +#define rt1015_tcon_bclk_sel_256fs (0x3 << 10) +#define rt1015_tcon_ch_len_mask (0x3 << 5) +#define rt1015_tcon_ch_len_sft 5 +#define rt1015_tcon_ch_len_16b (0x0 << 5) +#define rt1015_tcon_ch_len_20b (0x1 << 5) +#define rt1015_tcon_ch_len_24b (0x2 << 5) +#define rt1015_tcon_ch_len_32b (0x3 << 5) +#define rt1015_tcon_bclk_mst_mask (0x1 << 4) +#define rt1015_tcon_bclk_mst_sft 4 +#define rt1015_tcon_bclk_mst_inv (0x1 << 4) + +/* tdm1 setting-1 (0x0114) */ +#define rt1015_tdm_inv_bclk_mask (0x1 << 15) +#define rt1015_tdm_inv_bclk_sft 15 +#define rt1015_tdm_inv_bclk (0x1 << 15) + +/* 0x0330 */ +#define rt1015_abst_auto_en_mask (0x1 << 13) +#define rt1015_abst_auto_mode (0x1 << 13) +#define rt1015_abst_reg_mode (0x0 << 13) +#define rt1015_abst_fix_tgt_mask (0x1 << 12) +#define rt1015_abst_fix_tgt_en (0x1 << 12) +#define rt1015_abst_fix_tgt_dis (0x0 << 12) +#define rt1015_bypass_swr_reg_mask (0x1 << 7) +#define rt1015_bypass_swrreg_bypass (0x1 << 7) +#define rt1015_bypass_swrreg_pass (0x0 << 7) + +/* 0x0322 */ +#define rt1015_pwr_ldo2 (0x1 << 15) +#define rt1015_pwr_ldo2_bit 15 +#define rt1015_pwr_dac (0x1 << 14) +#define rt1015_pwr_dac_bit 14 +#define rt1015_pwr_intclk (0x1 << 13) +#define rt1015_pwr_intclk_bit 13 +#define rt1015_pwr_isense (0x1 << 12) +#define rt1015_pwr_isense_bit 12 +#define rt1015_pwr_vsense (0x1 << 10) +#define rt1015_pwr_vsense_bit 10 +#define rt1015_pwr_pll (0x1 << 9) +#define rt1015_pwr_pll_bit 9 +#define rt1015_pwr_bg_1_2 (0x1 << 8) +#define rt1015_pwr_bg_1_2_bit 8 +#define rt1015_pwr_mbias_bg (0x1 << 7) +#define rt1015_pwr_mbias_bg_bit 7 +#define rt1015_pwr_vbat (0x1 << 6) +#define rt1015_pwr_vbat_bit 6 +#define rt1015_pwr_mbias (0x1 << 4) +#define rt1015_pwr_mbias_bit 4 +#define rt1015_pwr_adcv (0x1 << 3) +#define rt1015_pwr_adcv_bit 3 +#define rt1015_pwr_mixerv (0x1 << 2) +#define rt1015_pwr_mixerv_bit 2 +#define rt1015_pwr_sumv (0x1 << 1) +#define rt1015_pwr_sumv_bit 1 +#define rt1015_pwr_vreflv (0x1 << 0) +#define rt1015_pwr_vreflv_bit 0 + +/* 0x0324 */ +#define rt1015_pwr_basic (0x1 << 15) +#define rt1015_pwr_basic_bit 15 +#define rt1015_pwr_sd (0x1 << 14) +#define rt1015_pwr_sd_bit 14 +#define rt1015_pwr_ibias (0x1 << 13) +#define rt1015_pwr_ibias_bit 13 +#define rt1015_pwr_vcm (0x1 << 11) +#define rt1015_pwr_vcm_bit 11 + +/* 0x0328 */ +#define rt1015_pwr_swr (0x1 << 12) +#define rt1015_pwr_swr_bit 12 + +/* 0x1300 */ +#define rt1015_pwr_clsd (0x1 << 12) +#define rt1015_pwr_clsd_bit 12 + +/* 0x007a */ +#define rt1015_id_mask 0xff +#define rt1015_id_vera 0x0 +#define rt1015_id_verb 0x1 + +/* system clock source */ +enum { + rt1015_sclk_s_mclk, + rt1015_sclk_s_pll, +}; + +/* pll1 source */ +enum { + rt1015_pll_s_mclk, + rt1015_pll_s_bclk, +}; + +enum { + rt1015_aif1, + rt1015_aifs, +}; + +enum { + rt1015_vera, + rt1015_verb, +}; + +enum { + bypass, + adaptive, + fixed_adaptive, +}; + +struct rt1015_priv { + struct snd_soc_component *component; + struct regmap *regmap; + int sysclk; + int sysclk_src; + int lrck; + int bclk; + int id; + int pll_src; + int pll_in; + int pll_out; + int boost_mode; + int bypass_boost; + int amp_ver; + int dac_is_used; +}; + +#endif /* __rt1015_h__ */
Audio
df31007400c3905ec15b1065241baf3864decbfa
jack yu
sound
soc
bindings, codecs, sound
asoc: rt1308-sdw: add rt1308 sdw amplifier driver
this is the initial amplifier driver for rt1308-sdw.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add rt1308 sdw amplifier driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'rt1308-sdw']
['c', 'kconfig', 'makefile', 'h']
4
913
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_rt1308_sdw if soundwire +config snd_soc_rt1308_sdw + tristate "realtek rt1308 codec - sdw" + depends on soundwire + select regmap_soundwire + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-rt1308-sdw-objs := rt1308-sdw.o +obj-$(config_snd_soc_rt1308_sdw) += snd-soc-rt1308-sdw.o diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c --- /dev/null +++ b/sound/soc/codecs/rt1308-sdw.c +// spdx-license-identifier: gpl-2.0 +// +// rt1308-sdw.c -- rt1308 alsa soc audio driver +// +// copyright(c) 2019 realtek semiconductor corp. +// +// +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/pm_runtime.h> +#include <linux/mod_devicetable.h> +#include <linux/soundwire/sdw.h> +#include <linux/soundwire/sdw_type.h> +#include <linux/soundwire/sdw_registers.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/initval.h> + +#include "rt1308.h" +#include "rt1308-sdw.h" + +static bool rt1308_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0: + case 0x00f0: + case 0x2f01 ... 0x2f07: + case 0x3000 ... 0x3001: + case 0x3004 ... 0x3005: + case 0x3008: + case 0x300a: + case 0xc000 ... 0xcff3: + return true; + default: + return false; + } +} + +static bool rt1308_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x2f01 ... 0x2f07: + case 0x3000 ... 0x3001: + case 0x3004 ... 0x3005: + case 0x3008: + case 0x300a: + case 0xc000: + return true; + default: + return false; + } +} + +static const struct regmap_config rt1308_sdw_regmap = { + .reg_bits = 32, + .val_bits = 8, + .readable_reg = rt1308_readable_register, + .volatile_reg = rt1308_volatile_register, + .max_register = 0xcfff, + .reg_defaults = rt1308_reg_defaults, + .num_reg_defaults = array_size(rt1308_reg_defaults), + .cache_type = regcache_rbtree, + .use_single_read = true, + .use_single_write = true, +}; + +/* bus clock frequency */ +#define rt1308_clk_freq_9600000hz 9600000 +#define rt1308_clk_freq_12000000hz 12000000 +#define rt1308_clk_freq_6000000hz 6000000 +#define rt1308_clk_freq_4800000hz 4800000 +#define rt1308_clk_freq_2400000hz 2400000 +#define rt1308_clk_freq_12288000hz 12288000 + +static int rt1308_clock_config(struct device *dev) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt1308->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case rt1308_clk_freq_12000000hz: + value = 0x0; + break; + case rt1308_clk_freq_6000000hz: + value = 0x1; + break; + case rt1308_clk_freq_9600000hz: + value = 0x2; + break; + case rt1308_clk_freq_4800000hz: + value = 0x3; + break; + case rt1308_clk_freq_2400000hz: + value = 0x4; + break; + case rt1308_clk_freq_12288000hz: + value = 0x5; + break; + default: + return -einval; + } + + regmap_write(rt1308->regmap, 0xe0, value); + regmap_write(rt1308->regmap, 0xf0, value); + + dev_dbg(dev, "%s complete, clk_freq=%d ", __func__, clk_freq); + + return 0; +} + +static int rt1308_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = true; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x00; /* bitmap: 00010100 (not enable yet) */ + prop->sink_ports = 0x2; /* bitmap: 00000010 */ + + /* for sink */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + gfp_kernel); + if (!prop->sink_dpn_prop) + return -enomem; + + i = 0; + dpn = prop->sink_dpn_prop; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = sdw_dpn_full; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + gfp_kernel); + if (!slave->port_ready) + return -enomem; + + /* initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + dev_dbg(&slave->dev, "%s ", __func__); + + return 0; +} + +static int rt1308_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + int ret = 0; + unsigned int efuse_m_btl_l, efuse_m_btl_r, tmp; + unsigned int efuse_c_btl_l, efuse_c_btl_r; + + if (rt1308->hw_init) + return 0; + + ret = rt1308_read_prop(slave); + if (ret < 0) + goto _io_init_err_; + + if (rt1308->first_hw_init) { + regcache_cache_only(rt1308->regmap, false); + regcache_cache_bypass(rt1308->regmap, true); + } + + /* + * pm runtime is only enabled when a slave reports as attached + */ + if (!rt1308->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + /* sw reset */ + regmap_write(rt1308->regmap, rt1308_sdw_reset, 0); + + /* read efuse */ + regmap_write(rt1308->regmap, 0xc360, 0x01); + regmap_write(rt1308->regmap, 0xc361, 0x80); + regmap_write(rt1308->regmap, 0xc7f0, 0x04); + regmap_write(rt1308->regmap, 0xc7f1, 0xfe); + msleep(100); + regmap_write(rt1308->regmap, 0xc7f0, 0x44); + msleep(20); + regmap_write(rt1308->regmap, 0xc240, 0x10); + + regmap_read(rt1308->regmap, 0xc861, &tmp); + efuse_m_btl_l = tmp; + regmap_read(rt1308->regmap, 0xc860, &tmp); + efuse_m_btl_l = efuse_m_btl_l | (tmp << 8); + regmap_read(rt1308->regmap, 0xc863, &tmp); + efuse_c_btl_l = tmp; + regmap_read(rt1308->regmap, 0xc862, &tmp); + efuse_c_btl_l = efuse_c_btl_l | (tmp << 8); + regmap_read(rt1308->regmap, 0xc871, &tmp); + efuse_m_btl_r = tmp; + regmap_read(rt1308->regmap, 0xc870, &tmp); + efuse_m_btl_r = efuse_m_btl_r | (tmp << 8); + regmap_read(rt1308->regmap, 0xc873, &tmp); + efuse_c_btl_r = tmp; + regmap_read(rt1308->regmap, 0xc872, &tmp); + efuse_c_btl_r = efuse_c_btl_r | (tmp << 8); + dev_info(&slave->dev, "%s m_btl_l=0x%x, m_btl_r=0x%x ", __func__, + efuse_m_btl_l, efuse_m_btl_r); + dev_info(&slave->dev, "%s c_btl_l=0x%x, c_btl_r=0x%x ", __func__, + efuse_c_btl_l, efuse_c_btl_r); + + /* initial settings */ + regmap_write(rt1308->regmap, 0xc103, 0xc0); + regmap_write(rt1308->regmap, 0xc030, 0x17); + regmap_write(rt1308->regmap, 0xc031, 0x81); + regmap_write(rt1308->regmap, 0xc032, 0x26); + regmap_write(rt1308->regmap, 0xc040, 0x80); + regmap_write(rt1308->regmap, 0xc041, 0x80); + regmap_write(rt1308->regmap, 0xc042, 0x06); + regmap_write(rt1308->regmap, 0xc052, 0x0a); + regmap_write(rt1308->regmap, 0xc080, 0x0a); + regmap_write(rt1308->regmap, 0xc060, 0x02); + regmap_write(rt1308->regmap, 0xc061, 0x75); + regmap_write(rt1308->regmap, 0xc062, 0x05); + regmap_write(rt1308->regmap, 0xc171, 0x07); + regmap_write(rt1308->regmap, 0xc173, 0x0d); + regmap_write(rt1308->regmap, 0xc311, 0x7f); + regmap_write(rt1308->regmap, 0xc900, 0x90); + regmap_write(rt1308->regmap, 0xc1a0, 0x84); + regmap_write(rt1308->regmap, 0xc1a1, 0x01); + regmap_write(rt1308->regmap, 0xc360, 0x78); + regmap_write(rt1308->regmap, 0xc361, 0x87); + regmap_write(rt1308->regmap, 0xc0a1, 0x71); + regmap_write(rt1308->regmap, 0xc210, 0x00); + regmap_write(rt1308->regmap, 0xc070, 0x00); + regmap_write(rt1308->regmap, 0xc100, 0xd7); + regmap_write(rt1308->regmap, 0xc101, 0xd7); + regmap_write(rt1308->regmap, 0xc300, 0x09); + + if (rt1308->first_hw_init) { + regcache_cache_bypass(rt1308->regmap, false); + regcache_mark_dirty(rt1308->regmap); + } else + rt1308->first_hw_init = true; + + /* mark slave initialization complete */ + rt1308->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + dev_dbg(&slave->dev, "%s hw_init complete ", __func__); + +_io_init_err_: + return ret; +} + +static int rt1308_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev); + + /* update the status */ + rt1308->status = status; + + if (status == sdw_slave_unattached) + rt1308->hw_init = false; + + /* + * perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt1308->hw_init || rt1308->status != sdw_slave_attached) + return 0; + + /* perform i/o transfers required for slave initialization */ + return rt1308_io_init(&slave->dev, slave); +} + +static int rt1308_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt1308->params, params, sizeof(*params)); + + ret = rt1308_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "invalid clk config"); + + return ret; +} + +static int rt1308_interrupt_callback(struct sdw_slave *slave, + struct sdw_slave_intr_status *status) +{ + dev_dbg(&slave->dev, + "%s control_port_stat=%x", __func__, status->control_port); + + return 0; +} + +static int rt1308_classd_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case snd_soc_dapm_post_pmu: + msleep(30); + snd_soc_component_update_bits(component, + rt1308_sdw_offset | (rt1308_power_status << 4), + 0x3, 0x3); + msleep(40); + break; + case snd_soc_dapm_pre_pmd: + snd_soc_component_update_bits(component, + rt1308_sdw_offset | (rt1308_power_status << 4), + 0x3, 0); + usleep_range(150000, 200000); + break; + + default: + break; + } + + return 0; +} + +static const char * const rt1308_rx_data_ch_select[] = { + "lr", + "ll", + "rl", + "rr", +}; + +static soc_enum_single_decl(rt1308_rx_data_ch_enum, + rt1308_sdw_offset | (rt1308_data_path << 4), 0, + rt1308_rx_data_ch_select); + +static const struct snd_kcontrol_new rt1308_snd_controls[] = { + + /* i2s data channel selection */ + soc_enum("rx channel select", rt1308_rx_data_ch_enum), +}; + +static const struct snd_kcontrol_new rt1308_sto_dac_l = + soc_dapm_single_autodisable("switch", + rt1308_sdw_offset_byte3 | (rt1308_dac_set << 4), + rt1308_dvol_mute_l_en_sft, 1, 1); + +static const struct snd_kcontrol_new rt1308_sto_dac_r = + soc_dapm_single_autodisable("switch", + rt1308_sdw_offset_byte3 | (rt1308_dac_set << 4), + rt1308_dvol_mute_r_en_sft, 1, 1); + +static const struct snd_soc_dapm_widget rt1308_dapm_widgets[] = { + /* audio interface */ + snd_soc_dapm_aif_in("aif1rx", "dp1 playback", 0, snd_soc_nopm, 0, 0), + + /* supply widgets */ + snd_soc_dapm_supply("mbias20u", + rt1308_sdw_offset | (rt1308_power << 4), 7, 0, null, 0), + snd_soc_dapm_supply("aldo", + rt1308_sdw_offset | (rt1308_power << 4), 6, 0, null, 0), + snd_soc_dapm_supply("dbg", + rt1308_sdw_offset | (rt1308_power << 4), 5, 0, null, 0), + snd_soc_dapm_supply("dacl", + rt1308_sdw_offset | (rt1308_power << 4), 4, 0, null, 0), + snd_soc_dapm_supply("clk25m", + rt1308_sdw_offset | (rt1308_power << 4), 2, 0, null, 0), + snd_soc_dapm_supply("adc_r", + rt1308_sdw_offset | (rt1308_power << 4), 1, 0, null, 0), + snd_soc_dapm_supply("adc_l", + rt1308_sdw_offset | (rt1308_power << 4), 0, 0, null, 0), + snd_soc_dapm_supply("dac power", + rt1308_sdw_offset | (rt1308_power << 4), 3, 0, null, 0), + + snd_soc_dapm_supply("dldo", + rt1308_sdw_offset_byte1 | (rt1308_power << 4), 5, 0, null, 0), + snd_soc_dapm_supply("vref", + rt1308_sdw_offset_byte1 | (rt1308_power << 4), 4, 0, null, 0), + snd_soc_dapm_supply("mixer_r", + rt1308_sdw_offset_byte1 | (rt1308_power << 4), 2, 0, null, 0), + snd_soc_dapm_supply("mixer_l", + rt1308_sdw_offset_byte1 | (rt1308_power << 4), 1, 0, null, 0), + snd_soc_dapm_supply("mbias4u", + rt1308_sdw_offset_byte1 | (rt1308_power << 4), 0, 0, null, 0), + + snd_soc_dapm_supply("pll2_ldo", + rt1308_sdw_offset_byte2 | (rt1308_power << 4), 4, 0, null, 0), + snd_soc_dapm_supply("pll2b", + rt1308_sdw_offset_byte2 | (rt1308_power << 4), 3, 0, null, 0), + snd_soc_dapm_supply("pll2f", + rt1308_sdw_offset_byte2 | (rt1308_power << 4), 2, 0, null, 0), + snd_soc_dapm_supply("pll2f2", + rt1308_sdw_offset_byte2 | (rt1308_power << 4), 1, 0, null, 0), + snd_soc_dapm_supply("pll2b2", + rt1308_sdw_offset_byte2 | (rt1308_power << 4), 0, 0, null, 0), + + /* digital interface */ + snd_soc_dapm_dac("dac", null, snd_soc_nopm, 0, 0), + snd_soc_dapm_switch("dac l", snd_soc_nopm, 0, 0, &rt1308_sto_dac_l), + snd_soc_dapm_switch("dac r", snd_soc_nopm, 0, 0, &rt1308_sto_dac_r), + + /* output lines */ + snd_soc_dapm_pga_e("class d", snd_soc_nopm, 0, 0, null, 0, + rt1308_classd_event, + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmu), + snd_soc_dapm_output("spol"), + snd_soc_dapm_output("spor"), +}; + +static const struct snd_soc_dapm_route rt1308_dapm_routes[] = { + + { "dac", null, "aif1rx" }, + + { "dac", null, "mbias20u" }, + { "dac", null, "aldo" }, + { "dac", null, "dbg" }, + { "dac", null, "dacl" }, + { "dac", null, "clk25m" }, + { "dac", null, "adc_r" }, + { "dac", null, "adc_l" }, + { "dac", null, "dldo" }, + { "dac", null, "vref" }, + { "dac", null, "mixer_r" }, + { "dac", null, "mixer_l" }, + { "dac", null, "mbias4u" }, + { "dac", null, "pll2_ldo" }, + { "dac", null, "pll2b" }, + { "dac", null, "pll2f" }, + { "dac", null, "pll2f2" }, + { "dac", null, "pll2b2" }, + + { "dac l", "switch", "dac" }, + { "dac r", "switch", "dac" }, + { "dac l", null, "dac power" }, + { "dac r", null, "dac power" }, + + { "class d", null, "dac l" }, + { "class d", null, "dac r" }, + { "spol", null, "class d" }, + { "spor", null, "class d" }, +}; + +static int rt1308_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), gfp_kernel); + if (!stream) + return -enomem; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == sndrv_pcm_stream_playback) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt1308_sdw_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, null); + kfree(stream); +} + +static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt1308_sdw_priv *rt1308 = + snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + + dev_dbg(dai->dev, "%s %s", __func__, dai->name); + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -einval; + + if (!rt1308->sdw_slave) + return -einval; + + /* soundwire specific configuration */ + /* port 1 for playback */ + if (substream->stream == sndrv_pcm_stream_playback) { + direction = sdw_data_dir_rx; + port = 1; + } else { + return -einval; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt1308->sdw_slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "unable to configure port "); + return retval; + } + + return retval; +} + +static int rt1308_sdw_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt1308_sdw_priv *rt1308 = + snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt1308->sdw_slave) + return -einval; + + sdw_stream_remove_slave(rt1308->sdw_slave, stream->sdw_stream); + return 0; +} + +/* + * slave_ops: callbacks for get_clock_stop_mode, clock_stop and + * port_prep are not defined for now + */ +static struct sdw_slave_ops rt1308_slave_ops = { + .read_prop = rt1308_read_prop, + .interrupt_callback = rt1308_interrupt_callback, + .update_status = rt1308_update_status, + .bus_config = rt1308_bus_config, +}; + +static const struct snd_soc_component_driver soc_component_sdw_rt1308 = { + .controls = rt1308_snd_controls, + .num_controls = array_size(rt1308_snd_controls), + .dapm_widgets = rt1308_dapm_widgets, + .num_dapm_widgets = array_size(rt1308_dapm_widgets), + .dapm_routes = rt1308_dapm_routes, + .num_dapm_routes = array_size(rt1308_dapm_routes), +}; + +static const struct snd_soc_dai_ops rt1308_aif_dai_ops = { + .hw_params = rt1308_sdw_hw_params, + .hw_free = rt1308_sdw_pcm_hw_free, + .set_sdw_stream = rt1308_set_sdw_stream, + .shutdown = rt1308_sdw_shutdown, +}; + +#define rt1308_stereo_rates sndrv_pcm_rate_48000 +#define rt1308_formats (sndrv_pcm_fmtbit_s8 | \ + sndrv_pcm_fmtbit_s20_3le | sndrv_pcm_fmtbit_s16_le | \ + sndrv_pcm_fmtbit_s24_le) + +static struct snd_soc_dai_driver rt1308_sdw_dai[] = { + { + .name = "rt1308-aif", + .playback = { + .stream_name = "dp1 playback", + .channels_min = 1, + .channels_max = 2, + .rates = rt1308_stereo_rates, + .formats = rt1308_formats, + }, + .ops = &rt1308_aif_dai_ops, + }, +}; + +static int rt1308_sdw_init(struct device *dev, struct regmap *regmap, + struct sdw_slave *slave) +{ + struct rt1308_sdw_priv *rt1308; + int ret; + + rt1308 = devm_kzalloc(dev, sizeof(*rt1308), gfp_kernel); + if (!rt1308) + return -enomem; + + dev_set_drvdata(dev, rt1308); + rt1308->sdw_slave = slave; + rt1308->regmap = regmap; + + /* + * mark hw_init to false + * hw init will be performed when device reports present + */ + rt1308->hw_init = false; + rt1308->first_hw_init = false; + + ret = devm_snd_soc_register_component(dev, + &soc_component_sdw_rt1308, + rt1308_sdw_dai, + array_size(rt1308_sdw_dai)); + + dev_dbg(&slave->dev, "%s ", __func__); + + return ret; +} + +static int rt1308_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *regmap; + + /* assign ops */ + slave->ops = &rt1308_slave_ops; + + /* regmap initialization */ + regmap = devm_regmap_init_sdw(slave, &rt1308_sdw_regmap); + if (!regmap) + return -einval; + + rt1308_sdw_init(&slave->dev, regmap, slave); + + return 0; +} + +static const struct sdw_device_id rt1308_id[] = { + sdw_slave_entry(0x025d, 0x1308, 0), + {}, +}; +module_device_table(sdw, rt1308_id); + +static int rt1308_dev_suspend(struct device *dev) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + + if (!rt1308->hw_init) + return 0; + + regcache_cache_only(rt1308->regmap, true); + + return 0; +} + +#define rt1308_probe_timeout 2000 + +static int rt1308_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = dev_to_sdw_dev(dev); + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt1308->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(rt1308_probe_timeout)); + if (!time) { + dev_err(&slave->dev, "initialization not complete, timed out "); + return -etimedout; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt1308->regmap, false); + regcache_sync_region(rt1308->regmap, 0xc000, 0xcfff); + + return 0; +} + +static const struct dev_pm_ops rt1308_pm = { + set_system_sleep_pm_ops(rt1308_dev_suspend, rt1308_dev_resume) + set_runtime_pm_ops(rt1308_dev_suspend, rt1308_dev_resume, null) +}; + +static struct sdw_driver rt1308_sdw_driver = { + .driver = { + .name = "rt1308", + .owner = this_module, + .pm = &rt1308_pm, + }, + .probe = rt1308_sdw_probe, + .ops = &rt1308_slave_ops, + .id_table = rt1308_id, +}; +module_sdw_driver(rt1308_sdw_driver); + +module_description("asoc rt1308 driver sdw"); +module_author("shuming fan <shumingf@realtek.com>"); +module_license("gpl v2"); diff --git a/sound/soc/codecs/rt1308-sdw.h b/sound/soc/codecs/rt1308-sdw.h --- /dev/null +++ b/sound/soc/codecs/rt1308-sdw.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * rt1308-sdw.h -- rt1308 alsa soc audio driver header + * + * copyright(c) 2019 realtek semiconductor corp. + */ + +#ifndef __rt1308_sdw_h__ +#define __rt1308_sdw_h__ + +static const struct reg_default rt1308_reg_defaults[] = { + { 0x0000, 0x00 }, + { 0x0001, 0x00 }, + { 0x0002, 0x00 }, + { 0x0003, 0x00 }, + { 0x0004, 0x00 }, + { 0x0005, 0x01 }, + { 0x0020, 0x00 }, + { 0x0022, 0x00 }, + { 0x0023, 0x00 }, + { 0x0024, 0x00 }, + { 0x0025, 0x00 }, + { 0x0026, 0x00 }, + { 0x0030, 0x00 }, + { 0x0032, 0x00 }, + { 0x0033, 0x00 }, + { 0x0034, 0x00 }, + { 0x0035, 0x00 }, + { 0x0036, 0x00 }, + { 0x0040, 0x00 }, + { 0x0041, 0x00 }, + { 0x0042, 0x00 }, + { 0x0043, 0x00 }, + { 0x0044, 0x20 }, + { 0x0045, 0x01 }, + { 0x0046, 0x01 }, + { 0x0048, 0x00 }, + { 0x0049, 0x00 }, + { 0x0050, 0x20 }, + { 0x0051, 0x02 }, + { 0x0052, 0x5d }, + { 0x0053, 0x13 }, + { 0x0054, 0x08 }, + { 0x0055, 0x00 }, + { 0x0060, 0x00 }, + { 0x0070, 0x00 }, + { 0x00e0, 0x00 }, + { 0x00f0, 0x00 }, + { 0x0100, 0x00 }, + { 0x0101, 0x00 }, + { 0x0102, 0x20 }, + { 0x0103, 0x00 }, + { 0x0104, 0x00 }, + { 0x0105, 0x03 }, + { 0x0120, 0x00 }, + { 0x0122, 0x00 }, + { 0x0123, 0x00 }, + { 0x0124, 0x00 }, + { 0x0125, 0x00 }, + { 0x0126, 0x00 }, + { 0x0127, 0x00 }, + { 0x0130, 0x00 }, + { 0x0132, 0x00 }, + { 0x0133, 0x00 }, + { 0x0134, 0x00 }, + { 0x0135, 0x00 }, + { 0x0136, 0x00 }, + { 0x0137, 0x00 }, + { 0x0200, 0x00 }, + { 0x0201, 0x00 }, + { 0x0202, 0x00 }, + { 0x0203, 0x00 }, + { 0x0204, 0x00 }, + { 0x0205, 0x03 }, + { 0x0220, 0x00 }, + { 0x0222, 0x00 }, + { 0x0223, 0x00 }, + { 0x0224, 0x00 }, + { 0x0225, 0x00 }, + { 0x0226, 0x00 }, + { 0x0227, 0x00 }, + { 0x0230, 0x00 }, + { 0x0232, 0x00 }, + { 0x0233, 0x00 }, + { 0x0234, 0x00 }, + { 0x0235, 0x00 }, + { 0x0236, 0x00 }, + { 0x0237, 0x00 }, + { 0x0400, 0x00 }, + { 0x0401, 0x00 }, + { 0x0402, 0x00 }, + { 0x0403, 0x00 }, + { 0x0404, 0x00 }, + { 0x0405, 0x03 }, + { 0x0420, 0x00 }, + { 0x0422, 0x00 }, + { 0x0423, 0x00 }, + { 0x0424, 0x00 }, + { 0x0425, 0x00 }, + { 0x0426, 0x00 }, + { 0x0427, 0x00 }, + { 0x0430, 0x00 }, + { 0x0432, 0x00 }, + { 0x0433, 0x00 }, + { 0x0434, 0x00 }, + { 0x0435, 0x00 }, + { 0x0436, 0x00 }, + { 0x0437, 0x00 }, + { 0x0f00, 0x00 }, + { 0x0f01, 0x00 }, + { 0x0f02, 0x00 }, + { 0x0f03, 0x00 }, + { 0x0f04, 0x00 }, + { 0x0f05, 0x00 }, + { 0x0f20, 0x00 }, + { 0x0f22, 0x00 }, + { 0x0f23, 0x00 }, + { 0x0f24, 0x00 }, + { 0x0f25, 0x00 }, + { 0x0f26, 0x00 }, + { 0x0f27, 0x00 }, + { 0x0f30, 0x00 }, + { 0x0f32, 0x00 }, + { 0x0f33, 0x00 }, + { 0x0f34, 0x00 }, + { 0x0f35, 0x00 }, + { 0x0f36, 0x00 }, + { 0x0f37, 0x00 }, + { 0x2f01, 0x01 }, + { 0x2f02, 0x09 }, + { 0x2f03, 0x00 }, + { 0x2f04, 0x0f }, + { 0x2f05, 0x0b }, + { 0x2f06, 0x01 }, + { 0x2f07, 0x8e }, + { 0x3000, 0x00 }, + { 0x3001, 0x00 }, + { 0x3004, 0x01 }, + { 0x3005, 0x23 }, + { 0x3008, 0x02 }, + { 0x300a, 0x00 }, + { 0xc003 | (rt1308_dac_set << 4), 0x00 }, + { 0xc001 | (rt1308_power << 4), 0x00 }, + { 0xc002 | (rt1308_power << 4), 0x00 }, +}; + +#define rt1308_sdw_offset 0xc000 +#define rt1308_sdw_offset_byte0 0xc000 +#define rt1308_sdw_offset_byte1 0xc001 +#define rt1308_sdw_offset_byte2 0xc002 +#define rt1308_sdw_offset_byte3 0xc003 + +#define rt1308_sdw_reset (rt1308_sdw_offset | (rt1308_reset << 4)) + +struct rt1308_sdw_priv { + struct snd_soc_component *component; + struct regmap *regmap; + struct sdw_slave *sdw_slave; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +#endif /* __rt1308_sdw_h__ */
Audio
a87a6653a28c0d511b3fdf3d62302bed5f325e03
shuming fan pierre louis bossart pierre louis bossart linux intel com
sound
soc
codecs
asoc: rt700: add rt700 codec driver
this is the initial codec driver for rt700.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add rt700 codec driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'rt700']
['c', 'kconfig', 'makefile', 'h']
6
2,310
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_rt700_sdw if soundwire +config snd_soc_rt700 + tristate + +config snd_soc_rt700_sdw + tristate "realtek rt700 codec - sdw" + depends on soundwire + select snd_soc_rt700 + select regmap_soundwire + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-rt700-objs := rt700.o rt700-sdw.o +obj-$(config_snd_soc_rt700) += snd-soc-rt700.o diff --git a/sound/soc/codecs/rt700-sdw.c b/sound/soc/codecs/rt700-sdw.c --- /dev/null +++ b/sound/soc/codecs/rt700-sdw.c +// spdx-license-identifier: gpl-2.0 +// +// rt700-sdw.c -- rt700 alsa soc audio driver +// +// copyright(c) 2019 realtek semiconductor corp. +// +// + +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/soundwire/sdw.h> +#include <linux/soundwire/sdw_type.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <sound/soc.h> +#include "rt700.h" +#include "rt700-sdw.h" + +static bool rt700_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0: + case 0x00f0: + case 0x2000 ... 0x200e: + case 0x2012 ... 0x2016: + case 0x201a ... 0x2027: + case 0x2029 ... 0x202a: + case 0x202d ... 0x2034: + case 0x2200 ... 0x2204: + case 0x2206 ... 0x2212: + case 0x2220 ... 0x2223: + case 0x2230 ... 0x2231: + case 0x3000 ... 0x3fff: + case 0x7000 ... 0x7fff: + case 0x8300 ... 0x83ff: + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0x75201a: + case 0x752045: + case 0x752046: + case 0x752048: + case 0x75204a: + case 0x75206b: + case 0x752080: + case 0x752081: + return true; + default: + return false; + } +} + +static bool rt700_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x2009: + case 0x2016: + case 0x201b: + case 0x201c: + case 0x201d: + case 0x201f: + case 0x2021: + case 0x2023: + case 0x2230: + case 0x200b ... 0x200e: /* i2c read */ + case 0x2012 ... 0x2015: /* hd-a read */ + case 0x202d ... 0x202f: /* bra */ + case 0x2201 ... 0x2212: /* i2c debug */ + case 0x2220 ... 0x2223: /* decoded hd-a */ + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0xff01: + case 0x75201a: + case 0x752046: + case 0x752080: + case 0x752081: + return true; + default: + return false; + } +} + +static int rt700_sdw_read(void *context, unsigned int reg, unsigned int *val) +{ + struct device *dev = context; + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned int sdw_data_3, sdw_data_2, sdw_data_1, sdw_data_0; + unsigned int reg2 = 0, reg3 = 0, reg4 = 0, mask, nid, val2; + unsigned int is_hda_reg = 1, is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt700->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = rt700_priv_data_r_h | nid; + ret = regmap_write(rt700->sdw_regmap, + reg3, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg4, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x3000) { + reg += 0x8000; + ret = regmap_write(rt700->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + reg += 0x2000; + reg |= 0x800; + ret = regmap_write(rt700->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for r channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt700->sdw_regmap, + reg2, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt700->sdw_regmap, reg, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x9000) { + ret = regmap_write(rt700->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0xb000) { + ret = regmap_write(rt700->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else { + ret = regmap_read(rt700->sdw_regmap, reg, val); + if (ret < 0) + return ret; + is_hda_reg = 0; + } + + if (is_hda_reg || is_index_reg) { + sdw_data_3 = 0; + sdw_data_2 = 0; + sdw_data_1 = 0; + sdw_data_0 = 0; + ret = regmap_read(rt700->sdw_regmap, + rt700_read_hda_3, &sdw_data_3); + if (ret < 0) + return ret; + ret = regmap_read(rt700->sdw_regmap, + rt700_read_hda_2, &sdw_data_2); + if (ret < 0) + return ret; + ret = regmap_read(rt700->sdw_regmap, + rt700_read_hda_1, &sdw_data_1); + if (ret < 0) + return ret; + ret = regmap_read(rt700->sdw_regmap, + rt700_read_hda_0, &sdw_data_0); + if (ret < 0) + return ret; + *val = ((sdw_data_3 & 0xff) << 24) | + ((sdw_data_2 & 0xff) << 16) | + ((sdw_data_1 & 0xff) << 8) | (sdw_data_0 & 0xff); + } + + if (is_hda_reg == 0) + dev_dbg(dev, "[%s] %04x => %08x ", __func__, reg, *val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x => %08x ", + __func__, reg, reg2, reg3, reg4, *val); + else + dev_dbg(dev, "[%s] %04x %04x => %08x ", + __func__, reg, reg2, *val); + + return 0; +} + +static int rt700_sdw_write(void *context, unsigned int reg, unsigned int val) +{ + struct device *dev = context; + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned int reg2 = 0, reg3, reg4, nid, mask, val2; + unsigned int is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt700->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = rt700_priv_data_w_h | nid; + ret = regmap_write(rt700->sdw_regmap, + reg3, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg4, (val & 0xff)); + if (ret < 0) + return ret; + is_index_reg = 1; + } else if (reg < 0x4fff) { + ret = regmap_write(rt700->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (reg == 0xff01) { + ret = regmap_write(rt700->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + ret = regmap_write(rt700->sdw_regmap, + reg, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, (val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for r channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt700->sdw_regmap, + reg2, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt700->sdw_regmap, reg, (val & 0xff)); + if (ret < 0) + return ret; + } + + if (reg2 == 0) + dev_dbg(dev, "[%s] %04x <= %04x ", __func__, reg, val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x <= %04x %04x ", + __func__, reg, reg2, reg3, reg4, val2, val); + else + dev_dbg(dev, "[%s] %04x %04x <= %04x ", + __func__, reg, reg2, val); + + return 0; +} + +static const struct regmap_config rt700_regmap = { + .reg_bits = 24, + .val_bits = 32, + .readable_reg = rt700_readable_register, + .volatile_reg = rt700_volatile_register, + .max_register = 0x755800, + .reg_defaults = rt700_reg_defaults, + .num_reg_defaults = array_size(rt700_reg_defaults), + .cache_type = regcache_rbtree, + .use_single_read = true, + .use_single_write = true, + .reg_read = rt700_sdw_read, + .reg_write = rt700_sdw_write, +}; + +static const struct regmap_config rt700_sdw_regmap = { + .name = "sdw", + .reg_bits = 32, + .val_bits = 8, + .readable_reg = rt700_readable_register, + .max_register = 0xff01, + .cache_type = regcache_none, + .use_single_read = true, + .use_single_write = true, +}; + +static int rt700_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + + /* update the status */ + rt700->status = status; + + if (status == sdw_slave_unattached) + rt700->hw_init = false; + + /* + * perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt700->hw_init || rt700->status != sdw_slave_attached) + return 0; + + /* perform i/o transfers required for slave initialization */ + return rt700_io_init(&slave->dev, slave); +} + +static int rt700_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = false; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x14; /* bitmap: 00010100 */ + prop->sink_ports = 0xa; /* bitmap: 00001010 */ + + nval = hweight32(prop->source_ports); + num_of_ports += nval; + prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->src_dpn_prop), + gfp_kernel); + if (!prop->src_dpn_prop) + return -enomem; + + i = 0; + dpn = prop->src_dpn_prop; + addr = prop->source_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = sdw_dpn_full; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* do this again for sink now */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + gfp_kernel); + if (!prop->sink_dpn_prop) + return -enomem; + + i = 0; + dpn = prop->sink_dpn_prop; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = sdw_dpn_full; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + gfp_kernel); + if (!slave->port_ready) + return -enomem; + + /* initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + /* wake-up event */ + prop->wake_capable = 1; + + return 0; +} + +static int rt700_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt700->params, params, sizeof(*params)); + + ret = rt700_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "invalid clk config"); + + return ret; +} + +static int rt700_interrupt_callback(struct sdw_slave *slave, + struct sdw_slave_intr_status *status) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + + dev_dbg(&slave->dev, + "%s control_port_stat=%x", __func__, status->control_port); + + if (status->control_port & 0x4) { + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_detect_work, msecs_to_jiffies(250)); + } + + return 0; +} + +/* + * slave_ops: callbacks for get_clock_stop_mode, clock_stop and + * port_prep are not defined for now + */ +static struct sdw_slave_ops rt700_slave_ops = { + .read_prop = rt700_read_prop, + .interrupt_callback = rt700_interrupt_callback, + .update_status = rt700_update_status, + .bus_config = rt700_bus_config, +}; + +static int rt700_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *sdw_regmap, *regmap; + + /* assign ops */ + slave->ops = &rt700_slave_ops; + + /* regmap initialization */ + sdw_regmap = devm_regmap_init_sdw(slave, &rt700_sdw_regmap); + if (!sdw_regmap) + return -einval; + + regmap = devm_regmap_init(&slave->dev, null, + &slave->dev, &rt700_regmap); + if (!regmap) + return -einval; + + rt700_init(&slave->dev, sdw_regmap, regmap, slave); + + return 0; +} + +static int rt700_sdw_remove(struct sdw_slave *slave) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + + if (rt700 && rt700->hw_init) { + cancel_delayed_work(&rt700->jack_detect_work); + cancel_delayed_work(&rt700->jack_btn_check_work); + } + + return 0; +} + +static const struct sdw_device_id rt700_id[] = { + sdw_slave_entry(0x025d, 0x700, 0), + {}, +}; +module_device_table(sdw, rt700_id); + +static int rt700_dev_suspend(struct device *dev) +{ + struct rt700_priv *rt700 = dev_get_drvdata(dev); + + if (!rt700->hw_init) + return 0; + + regcache_cache_only(rt700->regmap, true); + + return 0; +} + +#define rt700_probe_timeout 2000 + +static int rt700_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = dev_to_sdw_dev(dev); + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt700->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(rt700_probe_timeout)); + if (!time) { + dev_err(&slave->dev, "initialization not complete, timed out "); + return -etimedout; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt700->regmap, false); + regcache_sync_region(rt700->regmap, 0x3000, 0x8fff); + regcache_sync_region(rt700->regmap, 0x752010, 0x75206b); + + return 0; +} + +static const struct dev_pm_ops rt700_pm = { + set_system_sleep_pm_ops(rt700_dev_suspend, rt700_dev_resume) + set_runtime_pm_ops(rt700_dev_suspend, rt700_dev_resume, null) +}; + +static struct sdw_driver rt700_sdw_driver = { + .driver = { + .name = "rt700", + .owner = this_module, + .pm = &rt700_pm, + }, + .probe = rt700_sdw_probe, + .remove = rt700_sdw_remove, + .ops = &rt700_slave_ops, + .id_table = rt700_id, +}; +module_sdw_driver(rt700_sdw_driver); + +module_description("asoc rt700 driver sdw"); +module_author("shuming fan <shumingf@realtek.com>"); +module_license("gpl v2"); diff --git a/sound/soc/codecs/rt700-sdw.h b/sound/soc/codecs/rt700-sdw.h --- /dev/null +++ b/sound/soc/codecs/rt700-sdw.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * rt700-sdw.h -- rt700 alsa soc audio driver header + * + * copyright(c) 2019 realtek semiconductor corp. + */ + +#ifndef __rt700_sdw_h__ +#define __rt700_sdw_h__ + +static const struct reg_default rt700_reg_defaults[] = { + { 0x0000, 0x0000 }, + { 0x0001, 0x0000 }, + { 0x0002, 0x0000 }, + { 0x0003, 0x0000 }, + { 0x0004, 0x0000 }, + { 0x0005, 0x0001 }, + { 0x0020, 0x0000 }, + { 0x0022, 0x0000 }, + { 0x0023, 0x0000 }, + { 0x0024, 0x0000 }, + { 0x0025, 0x0000 }, + { 0x0026, 0x0000 }, + { 0x0030, 0x0000 }, + { 0x0032, 0x0000 }, + { 0x0033, 0x0000 }, + { 0x0034, 0x0000 }, + { 0x0035, 0x0000 }, + { 0x0036, 0x0000 }, + { 0x0040, 0x0000 }, + { 0x0041, 0x0000 }, + { 0x0042, 0x0000 }, + { 0x0043, 0x0000 }, + { 0x0044, 0x0020 }, + { 0x0045, 0x0001 }, + { 0x0046, 0x0000 }, + { 0x0050, 0x0000 }, + { 0x0051, 0x0000 }, + { 0x0052, 0x0000 }, + { 0x0053, 0x0000 }, + { 0x0054, 0x0000 }, + { 0x0055, 0x0000 }, + { 0x0060, 0x0000 }, + { 0x0070, 0x0000 }, + { 0x00e0, 0x0000 }, + { 0x00f0, 0x0000 }, + { 0x0100, 0x0000 }, + { 0x0101, 0x0000 }, + { 0x0102, 0x0000 }, + { 0x0103, 0x0000 }, + { 0x0104, 0x0000 }, + { 0x0105, 0x0000 }, + { 0x0120, 0x0000 }, + { 0x0121, 0x0000 }, + { 0x0122, 0x0000 }, + { 0x0123, 0x0000 }, + { 0x0124, 0x0000 }, + { 0x0125, 0x0000 }, + { 0x0126, 0x0000 }, + { 0x0127, 0x0000 }, + { 0x0130, 0x0000 }, + { 0x0131, 0x0000 }, + { 0x0132, 0x0000 }, + { 0x0133, 0x0000 }, + { 0x0134, 0x0000 }, + { 0x0135, 0x0000 }, + { 0x0136, 0x0000 }, + { 0x0137, 0x0000 }, + { 0x0200, 0x0000 }, + { 0x0201, 0x0000 }, + { 0x0202, 0x0000 }, + { 0x0203, 0x0000 }, + { 0x0204, 0x0000 }, + { 0x0205, 0x0000 }, + { 0x0220, 0x0000 }, + { 0x0221, 0x0000 }, + { 0x0222, 0x0000 }, + { 0x0223, 0x0000 }, + { 0x0224, 0x0000 }, + { 0x0225, 0x0000 }, + { 0x0226, 0x0000 }, + { 0x0227, 0x0000 }, + { 0x0230, 0x0000 }, + { 0x0231, 0x0000 }, + { 0x0232, 0x0000 }, + { 0x0233, 0x0000 }, + { 0x0234, 0x0000 }, + { 0x0235, 0x0000 }, + { 0x0236, 0x0000 }, + { 0x0237, 0x0000 }, + { 0x0300, 0x0000 }, + { 0x0301, 0x0000 }, + { 0x0302, 0x0000 }, + { 0x0303, 0x0000 }, + { 0x0304, 0x0000 }, + { 0x0305, 0x0000 }, + { 0x0320, 0x0000 }, + { 0x0321, 0x0000 }, + { 0x0322, 0x0000 }, + { 0x0323, 0x0000 }, + { 0x0324, 0x0000 }, + { 0x0325, 0x0000 }, + { 0x0326, 0x0000 }, + { 0x0327, 0x0000 }, + { 0x0330, 0x0000 }, + { 0x0331, 0x0000 }, + { 0x0332, 0x0000 }, + { 0x0333, 0x0000 }, + { 0x0334, 0x0000 }, + { 0x0335, 0x0000 }, + { 0x0336, 0x0000 }, + { 0x0337, 0x0000 }, + { 0x0400, 0x0000 }, + { 0x0401, 0x0000 }, + { 0x0402, 0x0000 }, + { 0x0403, 0x0000 }, + { 0x0404, 0x0000 }, + { 0x0405, 0x0000 }, + { 0x0420, 0x0000 }, + { 0x0421, 0x0000 }, + { 0x0422, 0x0000 }, + { 0x0423, 0x0000 }, + { 0x0424, 0x0000 }, + { 0x0425, 0x0000 }, + { 0x0426, 0x0000 }, + { 0x0427, 0x0000 }, + { 0x0430, 0x0000 }, + { 0x0431, 0x0000 }, + { 0x0432, 0x0000 }, + { 0x0433, 0x0000 }, + { 0x0434, 0x0000 }, + { 0x0435, 0x0000 }, + { 0x0436, 0x0000 }, + { 0x0437, 0x0000 }, + { 0x0500, 0x0000 }, + { 0x0501, 0x0000 }, + { 0x0502, 0x0000 }, + { 0x0503, 0x0000 }, + { 0x0504, 0x0000 }, + { 0x0505, 0x0000 }, + { 0x0520, 0x0000 }, + { 0x0521, 0x0000 }, + { 0x0522, 0x0000 }, + { 0x0523, 0x0000 }, + { 0x0524, 0x0000 }, + { 0x0525, 0x0000 }, + { 0x0526, 0x0000 }, + { 0x0527, 0x0000 }, + { 0x0530, 0x0000 }, + { 0x0531, 0x0000 }, + { 0x0532, 0x0000 }, + { 0x0533, 0x0000 }, + { 0x0534, 0x0000 }, + { 0x0535, 0x0000 }, + { 0x0536, 0x0000 }, + { 0x0537, 0x0000 }, + { 0x0600, 0x0000 }, + { 0x0601, 0x0000 }, + { 0x0602, 0x0000 }, + { 0x0603, 0x0000 }, + { 0x0604, 0x0000 }, + { 0x0605, 0x0000 }, + { 0x0620, 0x0000 }, + { 0x0621, 0x0000 }, + { 0x0622, 0x0000 }, + { 0x0623, 0x0000 }, + { 0x0624, 0x0000 }, + { 0x0625, 0x0000 }, + { 0x0626, 0x0000 }, + { 0x0627, 0x0000 }, + { 0x0630, 0x0000 }, + { 0x0631, 0x0000 }, + { 0x0632, 0x0000 }, + { 0x0633, 0x0000 }, + { 0x0634, 0x0000 }, + { 0x0635, 0x0000 }, + { 0x0636, 0x0000 }, + { 0x0637, 0x0000 }, + { 0x0700, 0x0000 }, + { 0x0701, 0x0000 }, + { 0x0702, 0x0000 }, + { 0x0703, 0x0000 }, + { 0x0704, 0x0000 }, + { 0x0705, 0x0000 }, + { 0x0720, 0x0000 }, + { 0x0721, 0x0000 }, + { 0x0722, 0x0000 }, + { 0x0723, 0x0000 }, + { 0x0724, 0x0000 }, + { 0x0725, 0x0000 }, + { 0x0726, 0x0000 }, + { 0x0727, 0x0000 }, + { 0x0730, 0x0000 }, + { 0x0731, 0x0000 }, + { 0x0732, 0x0000 }, + { 0x0733, 0x0000 }, + { 0x0734, 0x0000 }, + { 0x0735, 0x0000 }, + { 0x0736, 0x0000 }, + { 0x0737, 0x0000 }, + { 0x0800, 0x0000 }, + { 0x0801, 0x0000 }, + { 0x0802, 0x0000 }, + { 0x0803, 0x0000 }, + { 0x0804, 0x0000 }, + { 0x0805, 0x0000 }, + { 0x0820, 0x0000 }, + { 0x0821, 0x0000 }, + { 0x0822, 0x0000 }, + { 0x0823, 0x0000 }, + { 0x0824, 0x0000 }, + { 0x0825, 0x0000 }, + { 0x0826, 0x0000 }, + { 0x0827, 0x0000 }, + { 0x0830, 0x0000 }, + { 0x0831, 0x0000 }, + { 0x0832, 0x0000 }, + { 0x0833, 0x0000 }, + { 0x0834, 0x0000 }, + { 0x0835, 0x0000 }, + { 0x0836, 0x0000 }, + { 0x0837, 0x0000 }, + { 0x0f00, 0x0000 }, + { 0x0f01, 0x0000 }, + { 0x0f02, 0x0000 }, + { 0x0f03, 0x0000 }, + { 0x0f04, 0x0000 }, + { 0x0f05, 0x0000 }, + { 0x0f20, 0x0000 }, + { 0x0f21, 0x0000 }, + { 0x0f22, 0x0000 }, + { 0x0f23, 0x0000 }, + { 0x0f24, 0x0000 }, + { 0x0f25, 0x0000 }, + { 0x0f26, 0x0000 }, + { 0x0f27, 0x0000 }, + { 0x0f30, 0x0000 }, + { 0x0f31, 0x0000 }, + { 0x0f32, 0x0000 }, + { 0x0f33, 0x0000 }, + { 0x0f34, 0x0000 }, + { 0x0f35, 0x0000 }, + { 0x0f36, 0x0000 }, + { 0x0f37, 0x0000 }, + { 0x2000, 0x0000 }, + { 0x2001, 0x0000 }, + { 0x2002, 0x0000 }, + { 0x2003, 0x0000 }, + { 0x2004, 0x0000 }, + { 0x2005, 0x0000 }, + { 0x2006, 0x0000 }, + { 0x2007, 0x0000 }, + { 0x2008, 0x0000 }, + { 0x2009, 0x0003 }, + { 0x200a, 0x0003 }, + { 0x200b, 0x0000 }, + { 0x200c, 0x0000 }, + { 0x200d, 0x0000 }, + { 0x200e, 0x0000 }, + { 0x2012, 0x0000 }, + { 0x2013, 0x0000 }, + { 0x2014, 0x0000 }, + { 0x2015, 0x0000 }, + { 0x2016, 0x0000 }, + { 0x201a, 0x0000 }, + { 0x201b, 0x0000 }, + { 0x201c, 0x0000 }, + { 0x201d, 0x0000 }, + { 0x201e, 0x0000 }, + { 0x201f, 0x0000 }, + { 0x2020, 0x0000 }, + { 0x2021, 0x0000 }, + { 0x2022, 0x0000 }, + { 0x2023, 0x0000 }, + { 0x2024, 0x0000 }, + { 0x2025, 0x0002 }, + { 0x2026, 0x0000 }, + { 0x2027, 0x0000 }, + { 0x2029, 0x0000 }, + { 0x202a, 0x0000 }, + { 0x202d, 0x0000 }, + { 0x202e, 0x0000 }, + { 0x202f, 0x0000 }, + { 0x2030, 0x0000 }, + { 0x2031, 0x0000 }, + { 0x2032, 0x0000 }, + { 0x2033, 0x0000 }, + { 0x2034, 0x0000 }, + { 0x2200, 0x0000 }, + { 0x2201, 0x0000 }, + { 0x2202, 0x0000 }, + { 0x2203, 0x0000 }, + { 0x2204, 0x0000 }, + { 0x2206, 0x0000 }, + { 0x2207, 0x0000 }, + { 0x2208, 0x0000 }, + { 0x2209, 0x0000 }, + { 0x220a, 0x0000 }, + { 0x220b, 0x0000 }, + { 0x220c, 0x0000 }, + { 0x220d, 0x0000 }, + { 0x220e, 0x0000 }, + { 0x220f, 0x0000 }, + { 0x2211, 0x0000 }, + { 0x2212, 0x0000 }, + { 0x2220, 0x0000 }, + { 0x2221, 0x0000 }, + { 0x2222, 0x0000 }, + { 0x2223, 0x0000 }, + { 0x2230, 0x0000 }, + { 0x2231, 0x0000 }, + { 0x3121, 0x0001 }, + { 0x3122, 0x0000 }, + { 0x3123, 0x0000 }, + { 0x7303, 0x0057 }, + { 0x7303, 0x0057 }, + { 0x8383, 0x0057 }, + { 0x7308, 0x0097 }, + { 0x8388, 0x0097 }, + { 0x7309, 0x0097 }, + { 0x8389, 0x0097 }, + { 0x7312, 0x0000 }, + { 0x8392, 0x0000 }, + { 0x7313, 0x0000 }, + { 0x8393, 0x0000 }, + { 0x7319, 0x0000 }, + { 0x8399, 0x0000 }, + { 0x75201a, 0x8003 }, + { 0x752045, 0x5289 }, + { 0x752048, 0xd049 }, + { 0x75204a, 0xa83b }, + { 0x75206b, 0x5064 }, +}; + +#endif /* __rt700_h__ */ diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c --- /dev/null +++ b/sound/soc/codecs/rt700.c +// spdx-license-identifier: gpl-2.0 +// +// rt700.c -- rt700 alsa soc audio driver +// +// copyright(c) 2019 realtek semiconductor corp. +// +// + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/pm_runtime.h> +#include <linux/pm.h> +#include <linux/soundwire/sdw.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/initval.h> +#include <sound/tlv.h> +#include <sound/hda_verbs.h> +#include <sound/jack.h> + +#include "rt700.h" + +static int rt700_index_write(struct regmap *regmap, + unsigned int reg, unsigned int value) +{ + int ret; + unsigned int addr = (rt700_priv_index_w_h << 8) | reg; + + ret = regmap_write(regmap, addr, value); + if (ret < 0) + pr_err("failed to set private value: %06x <= %04x ret=%d ", + addr, value, ret); + + return ret; +} + +static int rt700_index_read(struct regmap *regmap, + unsigned int reg, unsigned int *value) +{ + int ret; + unsigned int addr = (rt700_priv_index_w_h << 8) | reg; + + *value = 0; + ret = regmap_read(regmap, addr, value); + if (ret < 0) + pr_err("failed to get private value: %06x => %04x ret=%d ", + addr, *value, ret); + + return ret; +} + +static unsigned int rt700_button_detect(struct rt700_priv *rt700) +{ + unsigned int btn_type = 0, val80, val81; + int ret; + + ret = rt700_index_read(rt700->regmap, rt700_irq_flag_table1, &val80); + if (ret < 0) + goto read_error; + ret = rt700_index_read(rt700->regmap, rt700_irq_flag_table2, &val81); + if (ret < 0) + goto read_error; + + val80 &= 0x0381; + val81 &= 0xff00; + + switch (val80) { + case 0x0200: + case 0x0100: + case 0x0080: + btn_type |= snd_jack_btn_0; + break; + case 0x0001: + btn_type |= snd_jack_btn_3; + break; + } + switch (val81) { + case 0x8000: + case 0x4000: + case 0x2000: + btn_type |= snd_jack_btn_1; + break; + case 0x1000: + case 0x0800: + case 0x0400: + btn_type |= snd_jack_btn_2; + break; + case 0x0200: + case 0x0100: + btn_type |= snd_jack_btn_3; + break; + } +read_error: + return btn_type; +} + +static int rt700_headset_detect(struct rt700_priv *rt700) +{ + unsigned int buf, loop = 0; + int ret; + unsigned int jack_status = 0, reg; + + ret = rt700_index_read(rt700->regmap, + rt700_combo_jack_auto_ctl2, &buf); + if (ret < 0) + goto io_error; + + while (loop < 500 && + (buf & rt700_combojack_auto_det_status) == 0) { + loop++; + + usleep_range(9000, 10000); + ret = rt700_index_read(rt700->regmap, + rt700_combo_jack_auto_ctl2, &buf); + if (ret < 0) + goto io_error; + + reg = rt700_verb_get_pin_sense | rt700_hp_out; + ret = regmap_read(rt700->regmap, reg, &jack_status); + if ((jack_status & (1 << 31)) == 0) + goto remove_error; + } + + if (loop >= 500) + goto to_error; + + if (buf & rt700_combojack_auto_det_trs) + rt700->jack_type = snd_jack_headphone; + else if ((buf & rt700_combojack_auto_det_ctia) || + (buf & rt700_combojack_auto_det_omtp)) + rt700->jack_type = snd_jack_headset; + + return 0; + +to_error: + ret = -etimedout; + pr_err_ratelimited("time-out error in %s ", __func__); + return ret; +io_error: + pr_err_ratelimited("io error in %s, ret %d ", __func__, ret); + return ret; +remove_error: + pr_err_ratelimited("jack removal in %s ", __func__); + return -enodev; +} + +static void rt700_jack_detect_handler(struct work_struct *work) +{ + struct rt700_priv *rt700 = + container_of(work, struct rt700_priv, jack_detect_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + if (!rt700->hs_jack) + return; + + if (!rt700->component->card->instantiated) + return; + + reg = rt700_verb_get_pin_sense | rt700_hp_out; + ret = regmap_read(rt700->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + /* jack in */ + if (rt700->jack_type == 0) { + ret = rt700_headset_detect(rt700); + if (ret < 0) + return; + if (rt700->jack_type == snd_jack_headset) + btn_type = rt700_button_detect(rt700); + } else if (rt700->jack_type == snd_jack_headset) { + /* jack is already in, report button event */ + btn_type = rt700_button_detect(rt700); + } + } else { + /* jack out */ + rt700->jack_type = 0; + } + + dev_dbg(&rt700->slave->dev, + "in %s, jack_type=0x%x ", __func__, rt700->jack_type); + dev_dbg(&rt700->slave->dev, + "in %s, btn_type=0x%x ", __func__, btn_type); + + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("io error in %s, ret %d ", __func__, ret); +} + +static void rt700_btn_check_handler(struct work_struct *work) +{ + struct rt700_priv *rt700 = container_of(work, struct rt700_priv, + jack_btn_check_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + reg = rt700_verb_get_pin_sense | rt700_hp_out; + ret = regmap_read(rt700->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + if (rt700->jack_type == snd_jack_headset) { + /* jack is already in, report button event */ + btn_type = rt700_button_detect(rt700); + } + } else { + rt700->jack_type = 0; + } + + /* cbj comparator */ + ret = rt700_index_read(rt700->regmap, rt700_combo_jack_auto_ctl2, &reg); + if (ret < 0) + goto io_error; + + if ((reg & 0xf0) == 0xf0) + btn_type = 0; + + dev_dbg(&rt700->slave->dev, + "%s, btn_type=0x%x ", __func__, btn_type); + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("io error in %s, ret %d ", __func__, ret); +} + +static void rt700_jack_init(struct rt700_priv *rt700) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(rt700->component); + + /* power on */ + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt700->regmap, + rt700_set_audio_power_state, ac_pwrst_d0); + + if (rt700->hs_jack) { + /* enable jack detection */ + regmap_write(rt700->regmap, + rt700_set_mic2_unsolicited_enable, 0x82); + regmap_write(rt700->regmap, + rt700_set_hp_unsolicited_enable, 0x81); + regmap_write(rt700->regmap, + rt700_set_inline_unsolicited_enable, 0x83); + rt700_index_write(rt700->regmap, 0x10, 0x2420); + rt700_index_write(rt700->regmap, 0x19, 0x2e11); + + dev_dbg(&rt700->slave->dev, "in %s enable ", __func__); + + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_detect_work, msecs_to_jiffies(250)); + } else { + regmap_write(rt700->regmap, + rt700_set_mic2_unsolicited_enable, 0x00); + regmap_write(rt700->regmap, + rt700_set_hp_unsolicited_enable, 0x00); + regmap_write(rt700->regmap, + rt700_set_inline_unsolicited_enable, 0x00); + + dev_dbg(&rt700->slave->dev, "in %s disable ", __func__); + } + + /* power off */ + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt700->regmap, + rt700_set_audio_power_state, ac_pwrst_d3); +} + +static int rt700_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hs_jack, void *data) +{ + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + rt700->hs_jack = hs_jack; + + if (!rt700->hw_init) { + dev_dbg(&rt700->slave->dev, + "%s hw_init not ready yet ", __func__); + return 0; + } + + rt700_jack_init(rt700); + + return 0; +} + +static void rt700_get_gain(struct rt700_priv *rt700, unsigned int addr_h, + unsigned int addr_l, unsigned int val_h, + unsigned int *r_val, unsigned int *l_val) +{ + /* r channel */ + *r_val = (val_h << 8); + regmap_read(rt700->regmap, addr_l, r_val); + + /* l channel */ + val_h |= 0x20; + *l_val = (val_h << 8); + regmap_read(rt700->regmap, addr_h, l_val); +} + +/* for verb-set amplifier gain (verb id = 3h) */ +static int rt700_set_amp_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int addr_h, addr_l, val_h, val_ll, val_lr; + unsigned int read_ll, read_rl; + int i; + + /* can't use update bit function, so read the original value first */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == rt700_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll); + + /* l channel */ + if (mc->invert) { + /* for mute */ + val_ll = (mc->max - ucontrol->value.integer.value[0]) << 7; + /* keep gain */ + read_ll = read_ll & 0x7f; + val_ll |= read_ll; + } else { + /* for gain */ + val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); + if (val_ll > mc->max) + val_ll = mc->max; + /* keep mute status */ + read_ll = read_ll & 0x80; + val_ll |= read_ll; + } + + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt700->regmap, + rt700_set_audio_power_state, ac_pwrst_d0); + + /* r channel */ + if (mc->invert) { + /* for mute */ + val_lr = (mc->max - ucontrol->value.integer.value[1]) << 7; + /* keep gain */ + read_rl = read_rl & 0x7f; + val_lr |= read_rl; + } else { + /* for gain */ + val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); + if (val_lr > mc->max) + val_lr = mc->max; + /* keep mute status */ + read_rl = read_rl & 0x80; + val_lr |= read_rl; + } + + for (i = 0; i < 3; i++) { /* retry 3 times at most */ + if (val_ll == val_lr) { + /* set both l/r channels at the same time */ + val_h = (1 << mc->shift) | (3 << 4); + regmap_write(rt700->regmap, + addr_h, (val_h << 8 | val_ll)); + regmap_write(rt700->regmap, + addr_l, (val_h << 8 | val_ll)); + } else { + /* lch*/ + val_h = (1 << mc->shift) | (1 << 5); + regmap_write(rt700->regmap, + addr_h, (val_h << 8 | val_ll)); + + /* rch */ + val_h = (1 << mc->shift) | (1 << 4); + regmap_write(rt700->regmap, + addr_l, (val_h << 8 | val_lr)); + } + /* check result */ + if (mc->shift == rt700_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt700_get_gain(rt700, addr_h, addr_l, val_h, + &read_rl, &read_ll); + if (read_rl == val_lr && read_ll == val_ll) + break; + } + + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt700->regmap, + rt700_set_audio_power_state, ac_pwrst_d3); + return 0; +} + +static int rt700_set_amp_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + unsigned int addr_h, addr_l, val_h; + unsigned int read_ll, read_rl; + + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == rt700_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll); + + if (mc->invert) { + /* for mute status */ + read_ll = !((read_ll & 0x80) >> rt700_mute_sft); + read_rl = !((read_rl & 0x80) >> rt700_mute_sft); + } else { + /* for gain */ + read_ll = read_ll & 0x7f; + read_rl = read_rl & 0x7f; + } + ucontrol->value.integer.value[0] = read_ll; + ucontrol->value.integer.value[1] = read_rl; + + return 0; +} + +static const declare_tlv_db_scale(out_vol_tlv, -6525, 75, 0); +static const declare_tlv_db_scale(in_vol_tlv, -1725, 75, 0); +static const declare_tlv_db_scale(mic_vol_tlv, 0, 1000, 0); + +static const struct snd_kcontrol_new rt700_snd_controls[] = { + soc_double_r_ext_tlv("dac front playback volume", + rt700_set_gain_dac1_h, rt700_set_gain_dac1_l, + rt700_dir_out_sft, 0x57, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, out_vol_tlv), + soc_double_r_ext("adc 08 capture switch", + rt700_set_gain_adc2_h, rt700_set_gain_adc2_l, + rt700_dir_in_sft, 1, 1, + rt700_set_amp_gain_get, rt700_set_amp_gain_put), + soc_double_r_ext("adc 09 capture switch", + rt700_set_gain_adc1_h, rt700_set_gain_adc1_l, + rt700_dir_in_sft, 1, 1, + rt700_set_amp_gain_get, rt700_set_amp_gain_put), + soc_double_r_ext_tlv("adc 08 capture volume", + rt700_set_gain_adc2_h, rt700_set_gain_adc2_l, + rt700_dir_in_sft, 0x3f, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, in_vol_tlv), + soc_double_r_ext_tlv("adc 09 capture volume", + rt700_set_gain_adc1_h, rt700_set_gain_adc1_l, + rt700_dir_in_sft, 0x3f, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, in_vol_tlv), + soc_double_r_ext_tlv("amic volume", + rt700_set_gain_amic_h, rt700_set_gain_amic_l, + rt700_dir_in_sft, 3, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, mic_vol_tlv), +}; + +static int rt700_mux_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int reg, val = 0, nid; + int ret; + + if (strstr(ucontrol->id.name, "hpo mux")) + nid = rt700_hp_out; + else if (strstr(ucontrol->id.name, "adc 22 mux")) + nid = rt700_mixer_in1; + else if (strstr(ucontrol->id.name, "adc 23 mux")) + nid = rt700_mixer_in2; + else + return -einval; + + /* vid = 0xf01 */ + reg = rt700_verb_set_connect_sel | nid; + ret = regmap_read(rt700->regmap, reg, &val); + if (ret < 0) + return ret; + + ucontrol->value.enumerated.item[0] = val; + + return 0; +} + +static int rt700_mux_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int *item = ucontrol->value.enumerated.item; + unsigned int val, val2 = 0, change, reg, nid; + int ret; + + if (item[0] >= e->items) + return -einval; + + if (strstr(ucontrol->id.name, "hpo mux")) + nid = rt700_hp_out; + else if (strstr(ucontrol->id.name, "adc 22 mux")) + nid = rt700_mixer_in1; + else if (strstr(ucontrol->id.name, "adc 23 mux")) + nid = rt700_mixer_in2; + else + return -einval; + + /* verb id = 0x701h */ + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; + + reg = rt700_verb_set_connect_sel | nid; + ret = regmap_read(rt700->regmap, reg, &val2); + if (ret < 0) + return ret; + + if (val == val2) + change = 0; + else + change = 1; + + if (change) { + reg = rt700_verb_set_connect_sel | nid; + regmap_write(rt700->regmap, reg, val); + } + + snd_soc_dapm_mux_update_power(dapm, kcontrol, + item[0], e, null); + + return change; +} + +static const char * const adc_mux_text[] = { + "mic2", + "line1", + "line2", + "dmic", +}; + +static soc_enum_single_decl( + rt700_adc22_enum, snd_soc_nopm, 0, adc_mux_text); + +static soc_enum_single_decl( + rt700_adc23_enum, snd_soc_nopm, 0, adc_mux_text); + +static const struct snd_kcontrol_new rt700_adc22_mux = + soc_dapm_enum_ext("adc 22 mux", rt700_adc22_enum, + rt700_mux_get, rt700_mux_put); + +static const struct snd_kcontrol_new rt700_adc23_mux = + soc_dapm_enum_ext("adc 23 mux", rt700_adc23_enum, + rt700_mux_get, rt700_mux_put); + +static const char * const out_mux_text[] = { + "front", + "surround", +}; + +static soc_enum_single_decl( + rt700_hp_enum, snd_soc_nopm, 0, out_mux_text); + +static const struct snd_kcontrol_new rt700_hp_mux = + soc_dapm_enum_ext("hp mux", rt700_hp_enum, + rt700_mux_get, rt700_mux_put); + +static int rt700_dac_front_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_post_pmu: + regmap_write(rt700->regmap, + rt700_set_streamid_dac1, 0x10); + break; + case snd_soc_dapm_pre_pmd: + regmap_write(rt700->regmap, + rt700_set_streamid_dac1, 0x00); + break; + } + return 0; +} + +static int rt700_dac_surround_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_post_pmu: + regmap_write(rt700->regmap, + rt700_set_streamid_dac2, 0x10); + break; + case snd_soc_dapm_pre_pmd: + regmap_write(rt700->regmap, + rt700_set_streamid_dac2, 0x00); + break; + } + return 0; +} + +static int rt700_adc_09_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_post_pmu: + regmap_write(rt700->regmap, + rt700_set_streamid_adc1, 0x10); + break; + case snd_soc_dapm_pre_pmd: + regmap_write(rt700->regmap, + rt700_set_streamid_adc1, 0x00); + break; + } + return 0; +} + +static int rt700_adc_08_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_post_pmu: + regmap_write(rt700->regmap, + rt700_set_streamid_adc2, 0x10); + break; + case snd_soc_dapm_pre_pmd: + regmap_write(rt700->regmap, + rt700_set_streamid_adc2, 0x00); + break; + } + return 0; +} + +static int rt700_hpo_mux_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int val_h = (1 << rt700_dir_out_sft) | (0x3 << 4); + unsigned int val_l; + + switch (event) { + case snd_soc_dapm_post_pmu: + val_l = 0x00; + regmap_write(rt700->regmap, + rt700_set_gain_hp_h, (val_h << 8 | val_l)); + break; + case snd_soc_dapm_pre_pmd: + val_l = (1 << rt700_mute_sft); + regmap_write(rt700->regmap, + rt700_set_gain_hp_h, (val_h << 8 | val_l)); + usleep_range(50000, 55000); + break; + } + return 0; +} + +static int rt700_spk_pga_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int val_h = (1 << rt700_dir_out_sft) | (0x3 << 4); + unsigned int val_l; + + switch (event) { + case snd_soc_dapm_post_pmu: + val_l = 0x00; + regmap_write(rt700->regmap, + rt700_set_gain_spk_h, (val_h << 8 | val_l)); + break; + case snd_soc_dapm_pre_pmd: + val_l = (1 << rt700_mute_sft); + regmap_write(rt700->regmap, + rt700_set_gain_spk_h, (val_h << 8 | val_l)); + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget rt700_dapm_widgets[] = { + snd_soc_dapm_output("hp"), + snd_soc_dapm_output("spk"), + snd_soc_dapm_input("dmic1"), + snd_soc_dapm_input("dmic2"), + snd_soc_dapm_input("mic2"), + snd_soc_dapm_input("line1"), + snd_soc_dapm_input("line2"), + snd_soc_dapm_dac_e("dac front", null, snd_soc_nopm, 0, 0, + rt700_dac_front_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_dac_e("dac surround", null, snd_soc_nopm, 0, 0, + rt700_dac_surround_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_mux_e("hpo mux", snd_soc_nopm, 0, 0, &rt700_hp_mux, + rt700_hpo_mux_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_pga_e("spk pga", snd_soc_nopm, 0, 0, null, 0, + rt700_spk_pga_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_adc_e("adc 09", null, snd_soc_nopm, 0, 0, + rt700_adc_09_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_adc_e("adc 08", null, snd_soc_nopm, 0, 0, + rt700_adc_08_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_mux("adc 22 mux", snd_soc_nopm, 0, 0, + &rt700_adc22_mux), + snd_soc_dapm_mux("adc 23 mux", snd_soc_nopm, 0, 0, + &rt700_adc23_mux), + snd_soc_dapm_aif_in("dp1rx", "dp1 playback", 0, snd_soc_nopm, 0, 0), + snd_soc_dapm_aif_in("dp3rx", "dp3 playback", 0, snd_soc_nopm, 0, 0), + snd_soc_dapm_aif_out("dp2tx", "dp2 capture", 0, snd_soc_nopm, 0, 0), + snd_soc_dapm_aif_out("dp4tx", "dp4 capture", 0, snd_soc_nopm, 0, 0), +}; + +static const struct snd_soc_dapm_route rt700_audio_map[] = { + {"dac front", null, "dp1rx"}, + {"dac surround", null, "dp3rx"}, + {"dp2tx", null, "adc 09"}, + {"dp4tx", null, "adc 08"}, + {"adc 09", null, "adc 22 mux"}, + {"adc 08", null, "adc 23 mux"}, + {"adc 22 mux", "dmic", "dmic1"}, + {"adc 22 mux", "line1", "line1"}, + {"adc 22 mux", "line2", "line2"}, + {"adc 22 mux", "mic2", "mic2"}, + {"adc 23 mux", "dmic", "dmic2"}, + {"adc 23 mux", "line1", "line1"}, + {"adc 23 mux", "line2", "line2"}, + {"adc 23 mux", "mic2", "mic2"}, + {"hpo mux", "front", "dac front"}, + {"hpo mux", "surround", "dac surround"}, + {"hp", null, "hpo mux"}, + {"spk pga", null, "dac front"}, + {"spk", null, "spk pga"}, +}; + +static int rt700_probe(struct snd_soc_component *component) +{ + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + rt700->component = component; + + return 0; +} + +static int rt700_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (level) { + case snd_soc_bias_prepare: + if (dapm->bias_level == snd_soc_bias_standby) { + regmap_write(rt700->regmap, + rt700_set_audio_power_state, + ac_pwrst_d0); + } + break; + + case snd_soc_bias_standby: + regmap_write(rt700->regmap, + rt700_set_audio_power_state, + ac_pwrst_d3); + break; + + default: + break; + } + dapm->bias_level = level; + return 0; +} + +static const struct snd_soc_component_driver soc_codec_dev_rt700 = { + .probe = rt700_probe, + .set_bias_level = rt700_set_bias_level, + .controls = rt700_snd_controls, + .num_controls = array_size(rt700_snd_controls), + .dapm_widgets = rt700_dapm_widgets, + .num_dapm_widgets = array_size(rt700_dapm_widgets), + .dapm_routes = rt700_audio_map, + .num_dapm_routes = array_size(rt700_audio_map), + .set_jack = rt700_set_jack_detect, +}; + +static int rt700_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), gfp_kernel); + if (!stream) + return -enomem; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == sndrv_pcm_stream_playback) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt700_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, null); + kfree(stream); +} + +static int rt700_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + unsigned int val = 0; + + dev_dbg(dai->dev, "%s %s", __func__, dai->name); + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -einval; + + if (!rt700->slave) + return -einval; + + /* soundwire specific configuration */ + /* this code assumes port 1 for playback and port 2 for capture */ + if (substream->stream == sndrv_pcm_stream_playback) { + direction = sdw_data_dir_rx; + port = 1; + } else { + direction = sdw_data_dir_tx; + port = 2; + } + + switch (dai->id) { + case rt700_aif1: + break; + case rt700_aif2: + port += 2; + break; + default: + dev_err(component->dev, "invalid dai id %d ", dai->id); + return -einval; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt700->slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "unable to configure port "); + return retval; + } + + if (params_channels(params) <= 16) { + /* bit 3:0 number of channel */ + val |= (params_channels(params) - 1); + } else { + dev_err(component->dev, "unsupported channels %d ", + params_channels(params)); + return -einval; + } + + switch (params_width(params)) { + /* bit 6:4 bits per sample */ + case 8: + break; + case 16: + val |= (0x1 << 4); + break; + case 20: + val |= (0x2 << 4); + break; + case 24: + val |= (0x3 << 4); + break; + case 32: + val |= (0x4 << 4); + break; + default: + return -einval; + } + + /* 48khz */ + regmap_write(rt700->regmap, rt700_dac_format_h, val); + regmap_write(rt700->regmap, rt700_adc_format_h, val); + + return retval; +} + +static int rt700_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt700->slave) + return -einval; + + sdw_stream_remove_slave(rt700->slave, stream->sdw_stream); + return 0; +} + +#define rt700_stereo_rates (sndrv_pcm_rate_44100 | sndrv_pcm_rate_48000) +#define rt700_formats (sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s20_3le | \ + sndrv_pcm_fmtbit_s24_le | sndrv_pcm_fmtbit_s8) + +static struct snd_soc_dai_ops rt700_ops = { + .hw_params = rt700_pcm_hw_params, + .hw_free = rt700_pcm_hw_free, + .set_sdw_stream = rt700_set_sdw_stream, + .shutdown = rt700_shutdown, +}; + +static struct snd_soc_dai_driver rt700_dai[] = { + { + .name = "rt700-aif1", + .id = rt700_aif1, + .playback = { + .stream_name = "dp1 playback", + .channels_min = 1, + .channels_max = 2, + .rates = rt700_stereo_rates, + .formats = rt700_formats, + }, + .capture = { + .stream_name = "dp2 capture", + .channels_min = 1, + .channels_max = 2, + .rates = rt700_stereo_rates, + .formats = rt700_formats, + }, + .ops = &rt700_ops, + }, + { + .name = "rt700-aif2", + .id = rt700_aif2, + .playback = { + .stream_name = "dp3 playback", + .channels_min = 1, + .channels_max = 2, + .rates = rt700_stereo_rates, + .formats = rt700_formats, + }, + .capture = { + .stream_name = "dp4 capture", + .channels_min = 1, + .channels_max = 2, + .rates = rt700_stereo_rates, + .formats = rt700_formats, + }, + .ops = &rt700_ops, + }, +}; + +/* bus clock frequency */ +#define rt700_clk_freq_9600000hz 9600000 +#define rt700_clk_freq_12000000hz 12000000 +#define rt700_clk_freq_6000000hz 6000000 +#define rt700_clk_freq_4800000hz 4800000 +#define rt700_clk_freq_2400000hz 2400000 +#define rt700_clk_freq_12288000hz 12288000 + +int rt700_clock_config(struct device *dev) +{ + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt700->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case rt700_clk_freq_12000000hz: + value = 0x0; + break; + case rt700_clk_freq_6000000hz: + value = 0x1; + break; + case rt700_clk_freq_9600000hz: + value = 0x2; + break; + case rt700_clk_freq_4800000hz: + value = 0x3; + break; + case rt700_clk_freq_2400000hz: + value = 0x4; + break; + case rt700_clk_freq_12288000hz: + value = 0x5; + break; + default: + return -einval; + } + + regmap_write(rt700->regmap, 0xe0, value); + regmap_write(rt700->regmap, 0xf0, value); + + dev_dbg(dev, "%s complete, clk_freq=%d ", __func__, clk_freq); + + return 0; +} + +int rt700_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave) + +{ + struct rt700_priv *rt700; + int ret; + + rt700 = devm_kzalloc(dev, sizeof(*rt700), gfp_kernel); + if (!rt700) + return -enomem; + + dev_set_drvdata(dev, rt700); + rt700->slave = slave; + rt700->sdw_regmap = sdw_regmap; + rt700->regmap = regmap; + + /* + * mark hw_init to false + * hw init will be performed when device reports present + */ + rt700->hw_init = false; + rt700->first_hw_init = false; + + ret = devm_snd_soc_register_component(dev, + &soc_codec_dev_rt700, + rt700_dai, + array_size(rt700_dai)); + + dev_dbg(&slave->dev, "%s ", __func__); + + return ret; +} + +int rt700_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt700_priv *rt700 = dev_get_drvdata(dev); + + if (rt700->hw_init) + return 0; + + if (rt700->first_hw_init) { + regcache_cache_only(rt700->regmap, false); + regcache_cache_bypass(rt700->regmap, true); + } + + /* + * pm runtime is only enabled when a slave reports as attached + */ + if (!rt700->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + /* reset */ + regmap_write(rt700->regmap, 0xff01, 0x0000); + regmap_write(rt700->regmap, 0x7520, 0x001a); + regmap_write(rt700->regmap, 0x7420, 0xc003); + + /* power on */ + regmap_write(rt700->regmap, rt700_set_audio_power_state, ac_pwrst_d0); + /* set pin widget */ + regmap_write(rt700->regmap, rt700_set_pin_hp, 0x40); + regmap_write(rt700->regmap, rt700_set_pin_spk, 0x40); + regmap_write(rt700->regmap, rt700_set_eapd_spk, rt700_eapd_high); + regmap_write(rt700->regmap, rt700_set_pin_dmic1, 0x20); + regmap_write(rt700->regmap, rt700_set_pin_dmic2, 0x20); + regmap_write(rt700->regmap, rt700_set_pin_mic2, 0x20); + + /* set configuration default */ + regmap_write(rt700->regmap, 0x4f12, 0x91); + regmap_write(rt700->regmap, 0x4e12, 0xd6); + regmap_write(rt700->regmap, 0x4d12, 0x11); + regmap_write(rt700->regmap, 0x4c12, 0x20); + regmap_write(rt700->regmap, 0x4f13, 0x91); + regmap_write(rt700->regmap, 0x4e13, 0xd6); + regmap_write(rt700->regmap, 0x4d13, 0x11); + regmap_write(rt700->regmap, 0x4c13, 0x21); + + regmap_write(rt700->regmap, 0x4f19, 0x02); + regmap_write(rt700->regmap, 0x4e19, 0xa1); + regmap_write(rt700->regmap, 0x4d19, 0x90); + regmap_write(rt700->regmap, 0x4c19, 0x80); + + /* enable line2 */ + regmap_write(rt700->regmap, 0x371b, 0x40); + regmap_write(rt700->regmap, 0x731b, 0xb0); + regmap_write(rt700->regmap, 0x839b, 0x00); + + /* set index */ + rt700_index_write(rt700->regmap, 0x4a, 0x201b); + rt700_index_write(rt700->regmap, 0x45, 0x5089); + rt700_index_write(rt700->regmap, 0x6b, 0x5064); + rt700_index_write(rt700->regmap, 0x48, 0xd249); + + /* finish initial settings, set power to d3 */ + regmap_write(rt700->regmap, rt700_set_audio_power_state, ac_pwrst_d3); + + if (!rt700->first_hw_init) { + init_delayed_work(&rt700->jack_detect_work, + rt700_jack_detect_handler); + init_delayed_work(&rt700->jack_btn_check_work, + rt700_btn_check_handler); + } + + /* + * if set_jack callback occurred early than io_init, + * we set up the jack detection function now + */ + if (rt700->hs_jack) + rt700_jack_init(rt700); + + if (rt700->first_hw_init) { + regcache_cache_bypass(rt700->regmap, false); + regcache_mark_dirty(rt700->regmap); + } else + rt700->first_hw_init = true; + + /* mark slave initialization complete */ + rt700->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + dev_dbg(&slave->dev, "%s hw_init complete ", __func__); + + return 0; +} + +module_description("asoc rt700 driver sdw"); +module_author("shuming fan <shumingf@realtek.com>"); +module_license("gpl v2"); diff --git a/sound/soc/codecs/rt700.h b/sound/soc/codecs/rt700.h --- /dev/null +++ b/sound/soc/codecs/rt700.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * rt700.h -- rt700 alsa soc audio driver header + * + * copyright(c) 2019 realtek semiconductor corp. + */ + +#ifndef __rt700_h__ +#define __rt700_h__ + +extern const struct dev_pm_ops rt700_runtime_pm; + +struct rt700_priv { + struct snd_soc_component *component; + struct regmap *regmap; + struct regmap *sdw_regmap; + struct sdw_slave *slave; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; + struct snd_soc_jack *hs_jack; + struct delayed_work jack_detect_work; + struct delayed_work jack_btn_check_work; + int jack_type; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +/* nid */ +#define rt700_audio_function_group 0x01 +#define rt700_dac_out1 0x02 +#define rt700_dac_out2 0x03 +#define rt700_adc_in1 0x09 +#define rt700_adc_in2 0x08 +#define rt700_dmic1 0x12 +#define rt700_dmic2 0x13 +#define rt700_spk_out 0x14 +#define rt700_mic2 0x19 +#define rt700_line1 0x1a +#define rt700_line2 0x1b +#define rt700_beep 0x1d +#define rt700_spdif 0x1e +#define rt700_vendor_registers 0x20 +#define rt700_hp_out 0x21 +#define rt700_mixer_in1 0x22 +#define rt700_mixer_in2 0x23 +#define rt700_inline_cmd 0x55 + +/* index (nid:20h) */ +#define rt700_dac_dc_cali_ctl1 0x00 +#define rt700_para_verb_ctl 0x1a +#define rt700_combo_jack_auto_ctl1 0x45 +#define rt700_combo_jack_auto_ctl2 0x46 +#define rt700_inline_cmd_ctl 0x48 +#define rt700_digital_misc_ctrl4 0x4a +#define rt700_vrefout_ctl 0x6b +#define rt700_fsm_ctl 0x6f +#define rt700_irq_flag_table1 0x80 +#define rt700_irq_flag_table2 0x81 +#define rt700_irq_flag_table3 0x82 + +/* verb */ +#define rt700_verb_set_connect_sel 0x3100 +#define rt700_verb_set_eapd_btlenable 0x3c00 +#define rt700_verb_get_connect_sel 0xb100 +#define rt700_verb_set_power_state 0x3500 +#define rt700_verb_set_channel_streamid 0x3600 +#define rt700_verb_set_pin_widget_control 0x3700 +#define rt700_verb_set_unsolicited_enable 0x3800 +#define rt700_set_amp_gain_mute_h 0x7300 +#define rt700_set_amp_gain_mute_l 0x8380 +#define rt700_verb_get_pin_sense 0xb900 + +#define rt700_read_hda_3 0x2012 +#define rt700_read_hda_2 0x2013 +#define rt700_read_hda_1 0x2014 +#define rt700_read_hda_0 0x2015 +#define rt700_priv_index_w_h 0x7520 +#define rt700_priv_index_w_l 0x85a0 +#define rt700_priv_data_w_h 0x7420 +#define rt700_priv_data_w_l 0x84a0 +#define rt700_priv_index_r_h 0x9d20 +#define rt700_priv_index_r_l 0xada0 +#define rt700_priv_data_r_h 0x9c20 +#define rt700_priv_data_r_l 0xaca0 +#define rt700_dac_format_h 0x7203 +#define rt700_dac_format_l 0x8283 +#define rt700_adc_format_h 0x7209 +#define rt700_adc_format_l 0x8289 +#define rt700_set_audio_power_state\ + (rt700_verb_set_power_state | rt700_audio_function_group) +#define rt700_set_pin_dmic1\ + (rt700_verb_set_pin_widget_control | rt700_dmic1) +#define rt700_set_pin_dmic2\ + (rt700_verb_set_pin_widget_control | rt700_dmic2) +#define rt700_set_pin_spk\ + (rt700_verb_set_pin_widget_control | rt700_spk_out) +#define rt700_set_pin_hp\ + (rt700_verb_set_pin_widget_control | rt700_hp_out) +#define rt700_set_pin_mic2\ + (rt700_verb_set_pin_widget_control | rt700_mic2) +#define rt700_set_pin_line1\ + (rt700_verb_set_pin_widget_control | rt700_line1) +#define rt700_set_pin_line2\ + (rt700_verb_set_pin_widget_control | rt700_line2) +#define rt700_set_mic2_unsolicited_enable\ + (rt700_verb_set_unsolicited_enable | rt700_mic2) +#define rt700_set_hp_unsolicited_enable\ + (rt700_verb_set_unsolicited_enable | rt700_hp_out) +#define rt700_set_inline_unsolicited_enable\ + (rt700_verb_set_unsolicited_enable | rt700_inline_cmd) +#define rt700_set_streamid_dac1\ + (rt700_verb_set_channel_streamid | rt700_dac_out1) +#define rt700_set_streamid_dac2\ + (rt700_verb_set_channel_streamid | rt700_dac_out2) +#define rt700_set_streamid_adc1\ + (rt700_verb_set_channel_streamid | rt700_adc_in1) +#define rt700_set_streamid_adc2\ + (rt700_verb_set_channel_streamid | rt700_adc_in2) +#define rt700_set_gain_dac1_l\ + (rt700_set_amp_gain_mute_l | rt700_dac_out1) +#define rt700_set_gain_dac1_h\ + (rt700_set_amp_gain_mute_h | rt700_dac_out1) +#define rt700_set_gain_adc1_l\ + (rt700_set_amp_gain_mute_l | rt700_adc_in1) +#define rt700_set_gain_adc1_h\ + (rt700_set_amp_gain_mute_h | rt700_adc_in1) +#define rt700_set_gain_adc2_l\ + (rt700_set_amp_gain_mute_l | rt700_adc_in2) +#define rt700_set_gain_adc2_h\ + (rt700_set_amp_gain_mute_h | rt700_adc_in2) +#define rt700_set_gain_amic_l\ + (rt700_set_amp_gain_mute_l | rt700_mic2) +#define rt700_set_gain_amic_h\ + (rt700_set_amp_gain_mute_h | rt700_mic2) +#define rt700_set_gain_hp_l\ + (rt700_set_amp_gain_mute_l | rt700_hp_out) +#define rt700_set_gain_hp_h\ + (rt700_set_amp_gain_mute_h | rt700_hp_out) +#define rt700_set_gain_spk_l\ + (rt700_set_amp_gain_mute_l | rt700_spk_out) +#define rt700_set_gain_spk_h\ + (rt700_set_amp_gain_mute_h | rt700_spk_out) +#define rt700_set_eapd_spk\ + (rt700_verb_set_eapd_btlenable | rt700_spk_out) + +/* combo jack auto switch control 2 (0x46)(nid:20h) */ +#define rt700_combojack_auto_det_status (0x1 << 11) +#define rt700_combojack_auto_det_trs (0x1 << 10) +#define rt700_combojack_auto_det_ctia (0x1 << 9) +#define rt700_combojack_auto_det_omtp (0x1 << 8) + +#define rt700_eapd_high 0x2 +#define rt700_eapd_low 0x0 +#define rt700_mute_sft 7 +#define rt700_dir_in_sft 6 +#define rt700_dir_out_sft 7 + +enum { + rt700_aif1, + rt700_aif2, + rt700_aifs, +}; + +int rt700_io_init(struct device *dev, struct sdw_slave *slave); +int rt700_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave); + +int rt700_jack_detect(struct rt700_priv *rt700, bool *hp, bool *mic); +int rt700_clock_config(struct device *dev); +#endif /* __rt700_h__ */
Audio
7d2a5f9ae41e3d3b50cd32b9fb307fab88064daf
shuming fan pierre louis bossart pierre louis bossart linux intel com
sound
soc
codecs
asoc: rt711: add rt711 codec driver
this is the initial codec driver for rt711.
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add rt711 codec driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'rt711']
['c', 'kconfig', 'makefile', 'h']
6
2,365
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_rt711_sdw if soundwire +config snd_soc_rt711 + tristate + +config snd_soc_rt711_sdw + tristate "realtek rt711 codec - sdw" + depends on soundwire + select snd_soc_rt711 + select regmap_soundwire + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-rt711-objs := rt711.o rt711-sdw.o +obj-$(config_snd_soc_rt711) += snd-soc-rt711.o diff --git a/sound/soc/codecs/rt711-sdw.c b/sound/soc/codecs/rt711-sdw.c --- /dev/null +++ b/sound/soc/codecs/rt711-sdw.c +// spdx-license-identifier: gpl-2.0 +// +// rt711-sdw.c -- rt711 alsa soc audio driver +// +// copyright(c) 2019 realtek semiconductor corp. +// +// + +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/soundwire/sdw.h> +#include <linux/soundwire/sdw_type.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <sound/soc.h> +#include "rt711.h" +#include "rt711-sdw.h" + +static bool rt711_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0: + case 0x00f0: + case 0x2012 ... 0x2016: + case 0x201a ... 0x2027: + case 0x2029 ... 0x202a: + case 0x202d ... 0x2034: + case 0x2201 ... 0x2204: + case 0x2206 ... 0x2212: + case 0x2220 ... 0x2223: + case 0x2230 ... 0x2239: + case 0x2f01 ... 0x2f0f: + case 0x3000 ... 0x3fff: + case 0x7000 ... 0x7fff: + case 0x8300 ... 0x83ff: + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0x752009: + case 0x752011: + case 0x75201a: + case 0x752045: + case 0x752046: + case 0x752048: + case 0x75204a: + case 0x75206b: + case 0x75206f: + case 0x752080: + case 0x752081: + case 0x752091: + case 0x755800: + return true; + default: + return false; + } +} + +static bool rt711_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x2016: + case 0x201b: + case 0x201c: + case 0x201d: + case 0x201f: + case 0x2021: + case 0x2023: + case 0x2230: + case 0x2012 ... 0x2015: /* hd-a read */ + case 0x202d ... 0x202f: /* bra */ + case 0x2201 ... 0x2212: /* i2c debug */ + case 0x2220 ... 0x2223: /* decoded hd-a */ + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0xff01: + case 0x75201a: + case 0x752046: + case 0x752080: + case 0x752081: + case 0x755800: + return true; + default: + return false; + } +} + +static int rt711_sdw_read(void *context, unsigned int reg, unsigned int *val) +{ + struct device *dev = context; + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned int sdw_data_3, sdw_data_2, sdw_data_1, sdw_data_0; + unsigned int reg2 = 0, reg3 = 0, reg4 = 0, mask, nid, val2; + unsigned int is_hda_reg = 1, is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt711->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = rt711_priv_data_r_h | nid; + ret = regmap_write(rt711->sdw_regmap, + reg3, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg4, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x3000) { + reg += 0x8000; + ret = regmap_write(rt711->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + reg += 0x2000; + reg |= 0x800; + ret = regmap_write(rt711->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for r channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt711->sdw_regmap, + reg2, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt711->sdw_regmap, reg, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x9000) { + ret = regmap_write(rt711->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0xb000) { + ret = regmap_write(rt711->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else { + ret = regmap_read(rt711->sdw_regmap, reg, val); + if (ret < 0) + return ret; + is_hda_reg = 0; + } + + if (is_hda_reg || is_index_reg) { + sdw_data_3 = 0; + sdw_data_2 = 0; + sdw_data_1 = 0; + sdw_data_0 = 0; + ret = regmap_read(rt711->sdw_regmap, + rt711_read_hda_3, &sdw_data_3); + if (ret < 0) + return ret; + ret = regmap_read(rt711->sdw_regmap, + rt711_read_hda_2, &sdw_data_2); + if (ret < 0) + return ret; + ret = regmap_read(rt711->sdw_regmap, + rt711_read_hda_1, &sdw_data_1); + if (ret < 0) + return ret; + ret = regmap_read(rt711->sdw_regmap, + rt711_read_hda_0, &sdw_data_0); + if (ret < 0) + return ret; + *val = ((sdw_data_3 & 0xff) << 24) | + ((sdw_data_2 & 0xff) << 16) | + ((sdw_data_1 & 0xff) << 8) | (sdw_data_0 & 0xff); + } + + if (is_hda_reg == 0) + dev_dbg(dev, "[%s] %04x => %08x ", __func__, reg, *val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x => %08x ", + __func__, reg, reg2, reg3, reg4, *val); + else + dev_dbg(dev, "[%s] %04x %04x => %08x ", + __func__, reg, reg2, *val); + + return 0; +} + +static int rt711_sdw_write(void *context, unsigned int reg, unsigned int val) +{ + struct device *dev = context; + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned int reg2 = 0, reg3, reg4, nid, mask, val2; + unsigned int is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt711->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = rt711_priv_data_w_h | nid; + ret = regmap_write(rt711->sdw_regmap, + reg3, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg4, (val & 0xff)); + if (ret < 0) + return ret; + is_index_reg = 1; + } else if (reg < 0x4fff) { + ret = regmap_write(rt711->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (reg == rt711_func_reset) { + ret = regmap_write(rt711->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + ret = regmap_write(rt711->sdw_regmap, + reg, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, (val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for r channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt711->sdw_regmap, + reg2, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt711->sdw_regmap, reg, (val & 0xff)); + if (ret < 0) + return ret; + } + + if (reg2 == 0) + dev_dbg(dev, "[%s] %04x <= %04x ", __func__, reg, val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x <= %04x %04x ", + __func__, reg, reg2, reg3, reg4, val2, val); + else + dev_dbg(dev, "[%s] %04x %04x <= %04x ", + __func__, reg, reg2, val); + + return 0; +} + +static const struct regmap_config rt711_regmap = { + .reg_bits = 24, + .val_bits = 32, + .readable_reg = rt711_readable_register, + .volatile_reg = rt711_volatile_register, + .max_register = 0x755800, + .reg_defaults = rt711_reg_defaults, + .num_reg_defaults = array_size(rt711_reg_defaults), + .cache_type = regcache_rbtree, + .use_single_read = true, + .use_single_write = true, + .reg_read = rt711_sdw_read, + .reg_write = rt711_sdw_write, +}; + +static const struct regmap_config rt711_sdw_regmap = { + .name = "sdw", + .reg_bits = 32, + .val_bits = 8, + .readable_reg = rt711_readable_register, + .max_register = 0xff01, + .cache_type = regcache_none, + .use_single_read = true, + .use_single_write = true, +}; + +static int rt711_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + + /* update the status */ + rt711->status = status; + + if (status == sdw_slave_unattached) + rt711->hw_init = false; + + /* + * perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt711->hw_init || rt711->status != sdw_slave_attached) + return 0; + + /* perform i/o transfers required for slave initialization */ + return rt711_io_init(&slave->dev, slave); +} + +static int rt711_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = false; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x14; /* bitmap: 00010100 */ + prop->sink_ports = 0x8; /* bitmap: 00001000 */ + + nval = hweight32(prop->source_ports); + num_of_ports += nval; + prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->src_dpn_prop), + gfp_kernel); + if (!prop->src_dpn_prop) + return -enomem; + + i = 0; + dpn = prop->src_dpn_prop; + addr = prop->source_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = sdw_dpn_full; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* do this again for sink now */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + gfp_kernel); + if (!prop->sink_dpn_prop) + return -enomem; + + i = 0; + dpn = prop->sink_dpn_prop; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = sdw_dpn_full; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + gfp_kernel); + if (!slave->port_ready) + return -enomem; + + /* initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + /* wake-up event */ + prop->wake_capable = 1; + + return 0; +} + +static int rt711_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt711->params, params, sizeof(*params)); + + ret = rt711_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "invalid clk config"); + + return ret; +} + +static int rt711_interrupt_callback(struct sdw_slave *slave, + struct sdw_slave_intr_status *status) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + + dev_dbg(&slave->dev, + "%s control_port_stat=%x", __func__, status->control_port); + + if (status->control_port & 0x4) { + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_detect_work, msecs_to_jiffies(250)); + } + + return 0; +} + +static struct sdw_slave_ops rt711_slave_ops = { + .read_prop = rt711_read_prop, + .interrupt_callback = rt711_interrupt_callback, + .update_status = rt711_update_status, + .bus_config = rt711_bus_config, +}; + +static int rt711_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *sdw_regmap, *regmap; + + /* assign ops */ + slave->ops = &rt711_slave_ops; + + /* regmap initialization */ + sdw_regmap = devm_regmap_init_sdw(slave, &rt711_sdw_regmap); + if (!sdw_regmap) + return -einval; + + regmap = devm_regmap_init(&slave->dev, null, + &slave->dev, &rt711_regmap); + if (!regmap) + return -einval; + + rt711_init(&slave->dev, sdw_regmap, regmap, slave); + + return 0; +} + +static int rt711_sdw_remove(struct sdw_slave *slave) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + + if (rt711 && rt711->hw_init) { + cancel_delayed_work(&rt711->jack_detect_work); + cancel_delayed_work(&rt711->jack_btn_check_work); + cancel_work_sync(&rt711->calibration_work); + } + + return 0; +} + +static const struct sdw_device_id rt711_id[] = { + sdw_slave_entry(0x025d, 0x711, 0), + {}, +}; +module_device_table(sdw, rt711_id); + +static int rt711_dev_suspend(struct device *dev) +{ + struct rt711_priv *rt711 = dev_get_drvdata(dev); + + if (!rt711->hw_init) + return 0; + + regcache_cache_only(rt711->regmap, true); + + return 0; +} + +#define rt711_probe_timeout 2000 + +static int rt711_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = dev_to_sdw_dev(dev); + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt711->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(rt711_probe_timeout)); + if (!time) { + dev_err(&slave->dev, "initialization not complete, timed out "); + return -etimedout; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt711->regmap, false); + regcache_sync_region(rt711->regmap, 0x3000, 0x8fff); + regcache_sync_region(rt711->regmap, 0x752009, 0x752091); + + return 0; +} + +static const struct dev_pm_ops rt711_pm = { + set_system_sleep_pm_ops(rt711_dev_suspend, rt711_dev_resume) + set_runtime_pm_ops(rt711_dev_suspend, rt711_dev_resume, null) +}; + +static struct sdw_driver rt711_sdw_driver = { + .driver = { + .name = "rt711", + .owner = this_module, + .pm = &rt711_pm, + }, + .probe = rt711_sdw_probe, + .remove = rt711_sdw_remove, + .ops = &rt711_slave_ops, + .id_table = rt711_id, +}; +module_sdw_driver(rt711_sdw_driver); + +module_description("asoc rt711 sdw driver"); +module_author("shuming fan <shumingf@realtek.com>"); +module_license("gpl"); diff --git a/sound/soc/codecs/rt711-sdw.h b/sound/soc/codecs/rt711-sdw.h --- /dev/null +++ b/sound/soc/codecs/rt711-sdw.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * rt711-sdw.h -- rt711 alsa soc audio driver header + * + * copyright(c) 2019 realtek semiconductor corp. + */ + +#ifndef __rt711_sdw_h__ +#define __rt711_sdw_h__ + +static const struct reg_default rt711_reg_defaults[] = { + { 0x0000, 0x00 }, + { 0x0001, 0x00 }, + { 0x0002, 0x00 }, + { 0x0003, 0x00 }, + { 0x0004, 0x00 }, + { 0x0005, 0x01 }, + { 0x0020, 0x00 }, + { 0x0022, 0x00 }, + { 0x0023, 0x00 }, + { 0x0024, 0x00 }, + { 0x0025, 0x00 }, + { 0x0026, 0x00 }, + { 0x0030, 0x00 }, + { 0x0032, 0x00 }, + { 0x0033, 0x00 }, + { 0x0034, 0x00 }, + { 0x0035, 0x00 }, + { 0x0036, 0x00 }, + { 0x0040, 0x00 }, + { 0x0041, 0x00 }, + { 0x0042, 0x00 }, + { 0x0043, 0x00 }, + { 0x0044, 0x20 }, + { 0x0045, 0x01 }, + { 0x0046, 0x01 }, + { 0x0050, 0x20 }, + { 0x0051, 0x02 }, + { 0x0052, 0x5d }, + { 0x0053, 0x07 }, + { 0x0054, 0x11 }, + { 0x0055, 0x00 }, + { 0x0060, 0x00 }, + { 0x0070, 0x00 }, + { 0x0080, 0xc0 }, + { 0x0088, 0x00 }, + { 0x00e0, 0x00 }, + { 0x00e1, 0x00 }, + { 0x00e2, 0x00 }, + { 0x00e3, 0x00 }, + { 0x00e5, 0x00 }, + { 0x00ee, 0x00 }, + { 0x00ef, 0x00 }, + { 0x00f0, 0x00 }, + { 0x00f1, 0x00 }, + { 0x00f2, 0x00 }, + { 0x00f3, 0x00 }, + { 0x00f4, 0x00 }, + { 0x00f5, 0x00 }, + { 0x00fe, 0x00 }, + { 0x00ff, 0x00 }, + { 0x0100, 0x00 }, + { 0x0101, 0x00 }, + { 0x0102, 0x00 }, + { 0x0103, 0x00 }, + { 0x0104, 0x00 }, + { 0x0105, 0x00 }, + { 0x0120, 0x00 }, + { 0x0122, 0x00 }, + { 0x0123, 0x00 }, + { 0x0124, 0x00 }, + { 0x0125, 0x00 }, + { 0x0126, 0x00 }, + { 0x0127, 0x00 }, + { 0x0130, 0x00 }, + { 0x0132, 0x00 }, + { 0x0133, 0x00 }, + { 0x0134, 0x00 }, + { 0x0135, 0x00 }, + { 0x0136, 0x00 }, + { 0x0137, 0x00 }, + { 0x0200, 0x00 }, + { 0x0201, 0x00 }, + { 0x0202, 0x00 }, + { 0x0203, 0x00 }, + { 0x0204, 0x00 }, + { 0x0205, 0x03 }, + { 0x0220, 0x00 }, + { 0x0222, 0x00 }, + { 0x0223, 0x00 }, + { 0x0224, 0x00 }, + { 0x0225, 0x00 }, + { 0x0226, 0x00 }, + { 0x0227, 0x00 }, + { 0x0230, 0x00 }, + { 0x0232, 0x00 }, + { 0x0233, 0x00 }, + { 0x0234, 0x00 }, + { 0x0235, 0x00 }, + { 0x0236, 0x00 }, + { 0x0237, 0x00 }, + { 0x0300, 0x00 }, + { 0x0301, 0x00 }, + { 0x0302, 0x20 }, + { 0x0303, 0x00 }, + { 0x0304, 0x00 }, + { 0x0305, 0x03 }, + { 0x0320, 0x00 }, + { 0x0322, 0x00 }, + { 0x0323, 0x00 }, + { 0x0324, 0x00 }, + { 0x0325, 0x00 }, + { 0x0326, 0x00 }, + { 0x0327, 0x00 }, + { 0x0330, 0x00 }, + { 0x0332, 0x00 }, + { 0x0333, 0x00 }, + { 0x0334, 0x00 }, + { 0x0335, 0x00 }, + { 0x0336, 0x00 }, + { 0x0337, 0x00 }, + { 0x0400, 0x00 }, + { 0x0401, 0x00 }, + { 0x0402, 0x00 }, + { 0x0403, 0x00 }, + { 0x0404, 0x00 }, + { 0x0405, 0x03 }, + { 0x0420, 0x00 }, + { 0x0422, 0x00 }, + { 0x0423, 0x00 }, + { 0x0424, 0x00 }, + { 0x0425, 0x00 }, + { 0x0426, 0x00 }, + { 0x0427, 0x00 }, + { 0x0430, 0x00 }, + { 0x0432, 0x00 }, + { 0x0433, 0x00 }, + { 0x0434, 0x00 }, + { 0x0435, 0x00 }, + { 0x0436, 0x00 }, + { 0x0437, 0x00 }, + { 0x0f00, 0x00 }, + { 0x0f01, 0x00 }, + { 0x0f02, 0x20 }, + { 0x0f03, 0x00 }, + { 0x0f04, 0x00 }, + { 0x0f05, 0x03 }, + { 0x0f06, 0x00 }, + { 0x0f07, 0x00 }, + { 0x0f08, 0x00 }, + { 0x0f09, 0x00 }, + { 0x0f10, 0x00 }, + { 0x0f11, 0x00 }, + { 0x0f12, 0x00 }, + { 0x0f13, 0x00 }, + { 0x0f14, 0x00 }, + { 0x0f15, 0x00 }, + { 0x0f16, 0x00 }, + { 0x0f17, 0x00 }, + { 0x0f18, 0x00 }, + { 0x0f19, 0x00 }, + { 0x0f1a, 0x00 }, + { 0x0f1b, 0x00 }, + { 0x0f1c, 0x00 }, + { 0x0f1d, 0x00 }, + { 0x0f1e, 0x00 }, + { 0x0f1f, 0x00 }, + { 0x0f20, 0x00 }, + { 0x0f22, 0x00 }, + { 0x0f23, 0x00 }, + { 0x0f24, 0x00 }, + { 0x0f25, 0x00 }, + { 0x0f26, 0x00 }, + { 0x0f27, 0x00 }, + { 0x0f30, 0x00 }, + { 0x0f32, 0x00 }, + { 0x0f33, 0x00 }, + { 0x0f34, 0x00 }, + { 0x0f35, 0x00 }, + { 0x0f36, 0x00 }, + { 0x0f37, 0x00 }, + { 0x2012, 0x00 }, + { 0x2013, 0x00 }, + { 0x2014, 0x00 }, + { 0x2015, 0x00 }, + { 0x2016, 0x00 }, + { 0x201a, 0x00 }, + { 0x201b, 0x00 }, + { 0x201c, 0x0c }, + { 0x201d, 0x00 }, + { 0x201e, 0x00 }, + { 0x201f, 0x00 }, + { 0x2020, 0x00 }, + { 0x2021, 0x00 }, + { 0x2022, 0x00 }, + { 0x2023, 0x00 }, + { 0x2024, 0x00 }, + { 0x2025, 0x01 }, + { 0x2026, 0x00 }, + { 0x2027, 0x00 }, + { 0x2029, 0x00 }, + { 0x202a, 0x00 }, + { 0x202d, 0x00 }, + { 0x202e, 0x00 }, + { 0x202f, 0x00 }, + { 0x2030, 0x00 }, + { 0x2031, 0x00 }, + { 0x2032, 0x00 }, + { 0x2033, 0x00 }, + { 0x2034, 0x00 }, + { 0x2201, 0xc7 }, + { 0x2202, 0x0c }, + { 0x2203, 0x22 }, + { 0x2204, 0x04 }, + { 0x2206, 0x00 }, + { 0x2207, 0x00 }, + { 0x2208, 0x00 }, + { 0x2209, 0x00 }, + { 0x220a, 0x00 }, + { 0x220b, 0x00 }, + { 0x220c, 0x00 }, + { 0x220d, 0x04 }, + { 0x220e, 0x00 }, + { 0x220f, 0x00 }, + { 0x2211, 0x01 }, + { 0x2212, 0x00 }, + { 0x2220, 0x00 }, + { 0x2221, 0x00 }, + { 0x2222, 0x00 }, + { 0x2223, 0x00 }, + { 0x2230, 0x00 }, + { 0x2231, 0x2f }, + { 0x2232, 0x80 }, + { 0x2233, 0x00 }, + { 0x2234, 0x00 }, + { 0x2235, 0x00 }, + { 0x2236, 0x00 }, + { 0x2237, 0x00 }, + { 0x2238, 0x00 }, + { 0x2239, 0x00 }, + { 0x2f01, 0x00 }, + { 0x2f02, 0x09 }, + { 0x2f03, 0x00 }, + { 0x2f04, 0x00 }, + { 0x2f05, 0x0b }, + { 0x2f06, 0x01 }, + { 0x2f07, 0xcf }, + { 0x2f08, 0x00 }, + { 0x2f09, 0x00 }, + { 0x2f0a, 0x00 }, + { 0x2f0b, 0x00 }, + { 0x2f0c, 0x00 }, + { 0x2f0d, 0x00 }, + { 0x2f0e, 0x00 }, + { 0x2f0f, 0x00 }, + { 0x3122, 0x00 }, + { 0x3123, 0x00 }, + { 0x7303, 0x57 }, + { 0x8383, 0x57 }, + { 0x7308, 0x97 }, + { 0x8388, 0x97 }, + { 0x7309, 0x97 }, + { 0x8389, 0x97 }, + { 0x7312, 0x00 }, + { 0x8392, 0x00 }, + { 0x7313, 0x00 }, + { 0x8393, 0x00 }, + { 0x7319, 0x00 }, + { 0x8399, 0x00 }, + { 0x752009, 0x1029 }, + { 0x752011, 0x007a }, + { 0x75201a, 0x8003 }, + { 0x752045, 0x5289 }, + { 0x752048, 0xd049 }, + { 0x75204a, 0xa83b }, + { 0x75206b, 0x5064 }, + { 0x75206f, 0x058b }, + { 0x752091, 0x0000 }, +}; + +#endif /* __rt711_sdw_h__ */ diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c --- /dev/null +++ b/sound/soc/codecs/rt711.c +// spdx-license-identifier: gpl-2.0 +// +// rt711.c -- rt711 alsa soc audio driver +// +// copyright(c) 2019 realtek semiconductor corp. +// +// + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/pm_runtime.h> +#include <linux/pm.h> +#include <linux/soundwire/sdw.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/initval.h> +#include <sound/tlv.h> +#include <sound/hda_verbs.h> +#include <sound/jack.h> + +#include "rt711.h" + +static int rt711_index_write(struct regmap *regmap, + unsigned int nid, unsigned int reg, unsigned int value) +{ + int ret; + unsigned int addr = ((rt711_priv_index_w_h | nid) << 8) | reg; + + ret = regmap_write(regmap, addr, value); + if (ret < 0) + pr_err("failed to set private value: %06x <= %04x ret=%d ", + addr, value, ret); + + return ret; +} + +static int rt711_index_read(struct regmap *regmap, + unsigned int nid, unsigned int reg, unsigned int *value) +{ + int ret; + unsigned int addr = ((rt711_priv_index_w_h | nid) << 8) | reg; + + *value = 0; + ret = regmap_read(regmap, addr, value); + if (ret < 0) + pr_err("failed to get private value: %06x => %04x ret=%d ", + addr, *value, ret); + + return ret; +} + +static int rt711_index_update_bits(struct regmap *regmap, unsigned int nid, + unsigned int reg, unsigned int mask, unsigned int val) +{ + unsigned int tmp, orig; + int ret; + + ret = rt711_index_read(regmap, nid, reg, &orig); + if (ret < 0) + return ret; + + tmp = orig & ~mask; + tmp |= val & mask; + + return rt711_index_write(regmap, nid, reg, tmp); +} + +static void rt711_reset(struct regmap *regmap) +{ + regmap_write(regmap, rt711_func_reset, 0); + rt711_index_update_bits(regmap, rt711_vendor_reg, + rt711_para_verb_ctl, rt711_hidden_reg_sw_reset, + rt711_hidden_reg_sw_reset); +} + +static int rt711_calibration(struct rt711_priv *rt711) +{ + unsigned int val, loop = 0; + struct device *dev; + struct regmap *regmap = rt711->regmap; + int ret = 0; + + mutex_lock(&rt711->calibrate_mutex); + regmap_write(rt711->regmap, + rt711_set_audio_power_state, ac_pwrst_d0); + + dev = regmap_get_device(regmap); + + /* calibration manual mode */ + rt711_index_update_bits(regmap, rt711_vendor_reg, rt711_fsm_ctl, + 0xf, 0x0); + + /* trigger */ + rt711_index_update_bits(regmap, rt711_vendor_cali, + rt711_dac_dc_cali_ctl1, rt711_dac_dc_cali_trigger, + rt711_dac_dc_cali_trigger); + + /* wait for calibration process */ + rt711_index_read(regmap, rt711_vendor_cali, + rt711_dac_dc_cali_ctl1, &val); + + while (val & rt711_dac_dc_cali_trigger) { + if (loop >= 500) { + pr_err("%s, calibration time-out! ", + __func__); + ret = -etimedout; + break; + } + loop++; + + usleep_range(10000, 11000); + rt711_index_read(regmap, rt711_vendor_cali, + rt711_dac_dc_cali_ctl1, &val); + } + + /* depop mode */ + rt711_index_update_bits(regmap, rt711_vendor_reg, + rt711_fsm_ctl, 0xf, rt711_depop_ctl); + + regmap_write(rt711->regmap, + rt711_set_audio_power_state, ac_pwrst_d3); + mutex_unlock(&rt711->calibrate_mutex); + + dev_dbg(dev, "%s calibration complete, ret=%d ", __func__, ret); + return ret; +} + +static unsigned int rt711_button_detect(struct rt711_priv *rt711) +{ + unsigned int btn_type = 0, val80, val81; + int ret; + + ret = rt711_index_read(rt711->regmap, rt711_vendor_reg, + rt711_irq_flag_table1, &val80); + if (ret < 0) + goto read_error; + ret = rt711_index_read(rt711->regmap, rt711_vendor_reg, + rt711_irq_flag_table2, &val81); + if (ret < 0) + goto read_error; + + val80 &= 0x0381; + val81 &= 0xff00; + + switch (val80) { + case 0x0200: + case 0x0100: + case 0x0080: + btn_type |= snd_jack_btn_0; + break; + case 0x0001: + btn_type |= snd_jack_btn_3; + break; + } + switch (val81) { + case 0x8000: + case 0x4000: + case 0x2000: + btn_type |= snd_jack_btn_1; + break; + case 0x1000: + case 0x0800: + case 0x0400: + btn_type |= snd_jack_btn_2; + break; + case 0x0200: + case 0x0100: + btn_type |= snd_jack_btn_3; + break; + } +read_error: + return btn_type; +} + +static int rt711_headset_detect(struct rt711_priv *rt711) +{ + unsigned int buf, loop = 0; + int ret; + unsigned int jack_status = 0, reg; + + ret = rt711_index_read(rt711->regmap, rt711_vendor_reg, + rt711_combo_jack_auto_ctl2, &buf); + if (ret < 0) + goto io_error; + + while (loop < 500 && + (buf & rt711_combojack_auto_det_status) == 0) { + loop++; + + usleep_range(9000, 10000); + ret = rt711_index_read(rt711->regmap, rt711_vendor_reg, + rt711_combo_jack_auto_ctl2, &buf); + if (ret < 0) + goto io_error; + + reg = rt711_verb_get_pin_sense | rt711_hp_out; + ret = regmap_read(rt711->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + if ((jack_status & (1 << 31)) == 0) + goto remove_error; + } + + if (loop >= 500) + goto to_error; + + if (buf & rt711_combojack_auto_det_trs) + rt711->jack_type = snd_jack_headphone; + else if ((buf & rt711_combojack_auto_det_ctia) || + (buf & rt711_combojack_auto_det_omtp)) + rt711->jack_type = snd_jack_headset; + + return 0; + +to_error: + ret = -etimedout; + pr_err_ratelimited("time-out error in %s ", __func__); + return ret; +io_error: + pr_err_ratelimited("io error in %s, ret %d ", __func__, ret); + return ret; +remove_error: + pr_err_ratelimited("jack removal in %s ", __func__); + return -enodev; +} + +static void rt711_jack_detect_handler(struct work_struct *work) +{ + struct rt711_priv *rt711 = + container_of(work, struct rt711_priv, jack_detect_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + if (!rt711->hs_jack) + return; + + if (!rt711->component->card->instantiated) + return; + + reg = rt711_verb_get_pin_sense | rt711_hp_out; + ret = regmap_read(rt711->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + /* jack in */ + if (rt711->jack_type == 0) { + ret = rt711_headset_detect(rt711); + if (ret < 0) + return; + if (rt711->jack_type == snd_jack_headset) + btn_type = rt711_button_detect(rt711); + } else if (rt711->jack_type == snd_jack_headset) { + /* jack is already in, report button event */ + btn_type = rt711_button_detect(rt711); + } + } else { + /* jack out */ + rt711->jack_type = 0; + } + + dev_dbg(&rt711->slave->dev, + "in %s, jack_type=0x%x ", __func__, rt711->jack_type); + dev_dbg(&rt711->slave->dev, + "in %s, btn_type=0x%x ", __func__, btn_type); + + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type | btn_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("io error in %s, ret %d ", __func__, ret); +} + +static void rt711_btn_check_handler(struct work_struct *work) +{ + struct rt711_priv *rt711 = container_of(work, struct rt711_priv, + jack_btn_check_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + reg = rt711_verb_get_pin_sense | rt711_hp_out; + ret = regmap_read(rt711->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + if (rt711->jack_type == snd_jack_headset) { + /* jack is already in, report button event */ + btn_type = rt711_button_detect(rt711); + } + } else { + rt711->jack_type = 0; + } + + /* cbj comparator */ + ret = rt711_index_read(rt711->regmap, rt711_vendor_reg, + rt711_combo_jack_auto_ctl2, &reg); + if (ret < 0) + goto io_error; + + if ((reg & 0xf0) == 0xf0) + btn_type = 0; + + dev_dbg(&rt711->slave->dev, + "%s, btn_type=0x%x ", __func__, btn_type); + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type | btn_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type, + snd_jack_headset | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3); + + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("io error in %s, ret %d ", __func__, ret); +} + +static void rt711_jack_init(struct rt711_priv *rt711) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(rt711->component); + + mutex_lock(&rt711->calibrate_mutex); + /* power on */ + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt711->regmap, + rt711_set_audio_power_state, ac_pwrst_d0); + + if (rt711->hs_jack) { + /* unsolicited response & irq control */ + regmap_write(rt711->regmap, + rt711_set_mic2_unsolicited_enable, 0x82); + regmap_write(rt711->regmap, + rt711_set_hp_unsolicited_enable, 0x81); + regmap_write(rt711->regmap, + rt711_set_inline_unsolicited_enable, 0x83); + rt711_index_write(rt711->regmap, rt711_vendor_reg, + 0x10, 0x2420); + rt711_index_write(rt711->regmap, rt711_vendor_reg, + 0x19, 0x2e11); + + switch (rt711->jd_src) { + case rt711_jd1: + /* default settings was already for jd1 */ + break; + case rt711_jd2: + rt711_index_update_bits(rt711->regmap, rt711_vendor_reg, + rt711_jd_ctl2, rt711_jd2_2port_200k_decode_hp | + rt711_hp_jd_sel_jd2, + rt711_jd2_2port_200k_decode_hp | + rt711_hp_jd_sel_jd2); + rt711_index_update_bits(rt711->regmap, rt711_vendor_reg, + rt711_cc_det1, + rt711_hp_jd_final_result_ctl_jd12, + rt711_hp_jd_final_result_ctl_jd12); + break; + default: + dev_warn(rt711->component->dev, "wrong jd source "); + break; + } + + dev_dbg(&rt711->slave->dev, "in %s enable ", __func__); + + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_detect_work, msecs_to_jiffies(250)); + } else { + regmap_write(rt711->regmap, + rt711_set_mic2_unsolicited_enable, 0x00); + regmap_write(rt711->regmap, + rt711_set_hp_unsolicited_enable, 0x00); + regmap_write(rt711->regmap, + rt711_set_inline_unsolicited_enable, 0x00); + + dev_dbg(&rt711->slave->dev, "in %s disable ", __func__); + } + + /* power off */ + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt711->regmap, + rt711_set_audio_power_state, ac_pwrst_d3); + mutex_unlock(&rt711->calibrate_mutex); +} + +static int rt711_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hs_jack, void *data) +{ + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + rt711->hs_jack = hs_jack; + + if (!rt711->hw_init) { + dev_dbg(&rt711->slave->dev, + "%s hw_init not ready yet ", __func__); + return 0; + } + + rt711_jack_init(rt711); + + return 0; +} + +static void rt711_get_gain(struct rt711_priv *rt711, unsigned int addr_h, + unsigned int addr_l, unsigned int val_h, + unsigned int *r_val, unsigned int *l_val) +{ + /* r channel */ + *r_val = (val_h << 8); + regmap_read(rt711->regmap, addr_l, r_val); + + /* l channel */ + val_h |= 0x20; + *l_val = (val_h << 8); + regmap_read(rt711->regmap, addr_h, l_val); +} + +/* for verb-set amplifier gain (verb id = 3h) */ +static int rt711_set_amp_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + unsigned int addr_h, addr_l, val_h, val_ll, val_lr; + unsigned int read_ll, read_rl; + int i; + + /* can't use update bit function, so read the original value first */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == rt711_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt711_get_gain(rt711, addr_h, addr_l, val_h, &read_rl, &read_ll); + + /* l channel */ + if (mc->invert) { + /* for mute/unmute */ + val_ll = (mc->max - ucontrol->value.integer.value[0]) + << rt711_mute_sft; + /* keep gain */ + read_ll = read_ll & 0x7f; + val_ll |= read_ll; + } else { + /* for gain */ + val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); + if (val_ll > mc->max) + val_ll = mc->max; + /* keep mute status */ + read_ll = read_ll & (1 << rt711_mute_sft); + val_ll |= read_ll; + } + + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt711->regmap, + rt711_set_audio_power_state, ac_pwrst_d0); + + /* r channel */ + if (mc->invert) { + /* for mute/unmute */ + val_lr = (mc->max - ucontrol->value.integer.value[1]) + << rt711_mute_sft; + /* keep gain */ + read_rl = read_rl & 0x7f; + val_lr |= read_rl; + } else { + /* for gain */ + val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); + if (val_lr > mc->max) + val_lr = mc->max; + /* keep mute status */ + read_rl = read_rl & (1 << rt711_mute_sft); + val_lr |= read_rl; + } + + for (i = 0; i < 3; i++) { /* retry 3 times at most */ + + if (val_ll == val_lr) { + /* set both l/r channels at the same time */ + val_h = (1 << mc->shift) | (3 << 4); + regmap_write(rt711->regmap, + addr_h, (val_h << 8 | val_ll)); + regmap_write(rt711->regmap, + addr_l, (val_h << 8 | val_ll)); + } else { + /* lch*/ + val_h = (1 << mc->shift) | (1 << 5); + regmap_write(rt711->regmap, + addr_h, (val_h << 8 | val_ll)); + + /* rch */ + val_h = (1 << mc->shift) | (1 << 4); + regmap_write(rt711->regmap, + addr_l, (val_h << 8 | val_lr)); + } + /* check result */ + if (mc->shift == rt711_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt711_get_gain(rt711, addr_h, addr_l, val_h, + &read_rl, &read_ll); + if (read_rl == val_lr && read_ll == val_ll) + break; + } + + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt711->regmap, + rt711_set_audio_power_state, ac_pwrst_d3); + return 0; +} + +static int rt711_set_amp_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + unsigned int addr_h, addr_l, val_h; + unsigned int read_ll, read_rl; + + /* switch to get command */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == rt711_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt711_get_gain(rt711, addr_h, addr_l, val_h, &read_rl, &read_ll); + + if (mc->invert) { + /* mute/unmute for switch controls */ + read_ll = !((read_ll & 0x80) >> rt711_mute_sft); + read_rl = !((read_rl & 0x80) >> rt711_mute_sft); + } else { + /* for gain volume controls */ + read_ll = read_ll & 0x7f; + read_rl = read_rl & 0x7f; + } + ucontrol->value.integer.value[0] = read_ll; + ucontrol->value.integer.value[1] = read_rl; + + return 0; +} + +static const declare_tlv_db_scale(out_vol_tlv, -6525, 75, 0); +static const declare_tlv_db_scale(in_vol_tlv, -1725, 75, 0); +static const declare_tlv_db_scale(mic_vol_tlv, 0, 1000, 0); + +static const struct snd_kcontrol_new rt711_snd_controls[] = { + soc_double_r_ext_tlv("dac surr playback volume", + rt711_set_gain_dac2_h, rt711_set_gain_dac2_l, + rt711_dir_out_sft, 0x57, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, out_vol_tlv), + soc_double_r_ext("adc 08 capture switch", + rt711_set_gain_adc2_h, rt711_set_gain_adc2_l, + rt711_dir_in_sft, 1, 1, + rt711_set_amp_gain_get, rt711_set_amp_gain_put), + soc_double_r_ext("adc 09 capture switch", + rt711_set_gain_adc1_h, rt711_set_gain_adc1_l, + rt711_dir_in_sft, 1, 1, + rt711_set_amp_gain_get, rt711_set_amp_gain_put), + soc_double_r_ext_tlv("adc 08 capture volume", + rt711_set_gain_adc2_h, rt711_set_gain_adc2_l, + rt711_dir_in_sft, 0x3f, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, in_vol_tlv), + soc_double_r_ext_tlv("adc 09 capture volume", + rt711_set_gain_adc1_h, rt711_set_gain_adc1_l, + rt711_dir_in_sft, 0x3f, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, in_vol_tlv), + soc_double_r_ext_tlv("amic volume", + rt711_set_gain_amic_h, rt711_set_gain_amic_l, + rt711_dir_in_sft, 3, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, mic_vol_tlv), + soc_double_r_ext_tlv("dmic1 volume", + rt711_set_gain_dmic1_h, rt711_set_gain_dmic1_l, + rt711_dir_in_sft, 3, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, mic_vol_tlv), + soc_double_r_ext_tlv("dmic2 volume", + rt711_set_gain_dmic2_h, rt711_set_gain_dmic2_l, + rt711_dir_in_sft, 3, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, mic_vol_tlv), +}; + +static int rt711_mux_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + unsigned int reg, val = 0, nid; + int ret; + + if (strstr(ucontrol->id.name, "adc 22 mux")) + nid = rt711_mixer_in1; + else if (strstr(ucontrol->id.name, "adc 23 mux")) + nid = rt711_mixer_in2; + else + return -einval; + + /* vid = 0xf01 */ + reg = rt711_verb_set_connect_sel | nid; + ret = regmap_read(rt711->regmap, reg, &val); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d ", + __func__, ret); + return ret; + } + + ucontrol->value.enumerated.item[0] = val; + + return 0; +} + +static int rt711_mux_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int *item = ucontrol->value.enumerated.item; + unsigned int val, val2 = 0, change, reg, nid; + int ret; + + if (item[0] >= e->items) + return -einval; + + if (strstr(ucontrol->id.name, "adc 22 mux")) + nid = rt711_mixer_in1; + else if (strstr(ucontrol->id.name, "adc 23 mux")) + nid = rt711_mixer_in2; + else + return -einval; + + /* verb id = 0x701h */ + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; + + reg = rt711_verb_set_connect_sel | nid; + ret = regmap_read(rt711->regmap, reg, &val2); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d ", + __func__, ret); + return ret; + } + + if (val == val2) + change = 0; + else + change = 1; + + if (change) { + reg = rt711_verb_set_connect_sel | nid; + regmap_write(rt711->regmap, reg, val); + } + + snd_soc_dapm_mux_update_power(dapm, kcontrol, + item[0], e, null); + + return change; +} + +static const char * const adc_mux_text[] = { + "mic2", + "line1", + "line2", + "dmic", +}; + +static soc_enum_single_decl( + rt711_adc22_enum, snd_soc_nopm, 0, adc_mux_text); + +static soc_enum_single_decl( + rt711_adc23_enum, snd_soc_nopm, 0, adc_mux_text); + +static const struct snd_kcontrol_new rt711_adc22_mux = + soc_dapm_enum_ext("adc 22 mux", rt711_adc22_enum, + rt711_mux_get, rt711_mux_put); + +static const struct snd_kcontrol_new rt711_adc23_mux = + soc_dapm_enum_ext("adc 23 mux", rt711_adc23_enum, + rt711_mux_get, rt711_mux_put); + +static int rt711_dac_surround_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + unsigned int val_h = (1 << rt711_dir_out_sft) | (0x3 << 4); + unsigned int val_l; + + switch (event) { + case snd_soc_dapm_post_pmu: + regmap_write(rt711->regmap, + rt711_set_streamid_dac2, 0x10); + + val_l = 0x00; + regmap_write(rt711->regmap, + rt711_set_gain_hp_h, (val_h << 8 | val_l)); + break; + case snd_soc_dapm_pre_pmd: + val_l = (1 << rt711_mute_sft); + regmap_write(rt711->regmap, + rt711_set_gain_hp_h, (val_h << 8 | val_l)); + usleep_range(50000, 55000); + + regmap_write(rt711->regmap, + rt711_set_streamid_dac2, 0x00); + break; + } + return 0; +} + +static int rt711_adc_09_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_post_pmu: + regmap_write(rt711->regmap, + rt711_set_streamid_adc1, 0x10); + break; + case snd_soc_dapm_pre_pmd: + regmap_write(rt711->regmap, + rt711_set_streamid_adc1, 0x00); + break; + } + return 0; +} + +static int rt711_adc_08_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_post_pmu: + regmap_write(rt711->regmap, + rt711_set_streamid_adc2, 0x10); + break; + case snd_soc_dapm_pre_pmd: + regmap_write(rt711->regmap, + rt711_set_streamid_adc2, 0x00); + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget rt711_dapm_widgets[] = { + snd_soc_dapm_output("hp"), + snd_soc_dapm_input("mic2"), + snd_soc_dapm_input("dmic1"), + snd_soc_dapm_input("dmic2"), + snd_soc_dapm_input("line1"), + snd_soc_dapm_input("line2"), + + snd_soc_dapm_dac_e("dac surround", null, snd_soc_nopm, 0, 0, + rt711_dac_surround_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_adc_e("adc 09", null, snd_soc_nopm, 0, 0, + rt711_adc_09_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_adc_e("adc 08", null, snd_soc_nopm, 0, 0, + rt711_adc_08_event, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_mux("adc 22 mux", snd_soc_nopm, 0, 0, + &rt711_adc22_mux), + snd_soc_dapm_mux("adc 23 mux", snd_soc_nopm, 0, 0, + &rt711_adc23_mux), + + snd_soc_dapm_aif_in("dp3rx", "dp3 playback", 0, snd_soc_nopm, 0, 0), + snd_soc_dapm_aif_out("dp2tx", "dp2 capture", 0, snd_soc_nopm, 0, 0), + snd_soc_dapm_aif_out("dp4tx", "dp4 capture", 0, snd_soc_nopm, 0, 0), +}; + +static const struct snd_soc_dapm_route rt711_audio_map[] = { + {"dac surround", null, "dp3rx"}, + {"dp2tx", null, "adc 09"}, + {"dp4tx", null, "adc 08"}, + + {"adc 09", null, "adc 22 mux"}, + {"adc 08", null, "adc 23 mux"}, + {"adc 22 mux", "dmic", "dmic1"}, + {"adc 22 mux", "line1", "line1"}, + {"adc 22 mux", "line2", "line2"}, + {"adc 22 mux", "mic2", "mic2"}, + {"adc 23 mux", "dmic", "dmic2"}, + {"adc 23 mux", "line1", "line1"}, + {"adc 23 mux", "line2", "line2"}, + {"adc 23 mux", "mic2", "mic2"}, + + {"hp", null, "dac surround"}, +}; + +static int rt711_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + switch (level) { + case snd_soc_bias_prepare: + if (dapm->bias_level == snd_soc_bias_standby) { + regmap_write(rt711->regmap, + rt711_set_audio_power_state, + ac_pwrst_d0); + } + break; + + case snd_soc_bias_standby: + regmap_write(rt711->regmap, + rt711_set_audio_power_state, + ac_pwrst_d3); + break; + + default: + break; + } + + return 0; +} + +static int rt711_parse_dt(struct rt711_priv *rt711, struct device *dev) +{ + device_property_read_u32(dev, "realtek,jd-src", + &rt711->jd_src); + + return 0; +} + +static int rt711_probe(struct snd_soc_component *component) +{ + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + rt711_parse_dt(rt711, &rt711->slave->dev); + rt711->component = component; + + return 0; +} + +static const struct snd_soc_component_driver soc_codec_dev_rt711 = { + .probe = rt711_probe, + .set_bias_level = rt711_set_bias_level, + .controls = rt711_snd_controls, + .num_controls = array_size(rt711_snd_controls), + .dapm_widgets = rt711_dapm_widgets, + .num_dapm_widgets = array_size(rt711_dapm_widgets), + .dapm_routes = rt711_audio_map, + .num_dapm_routes = array_size(rt711_audio_map), + .set_jack = rt711_set_jack_detect, +}; + +static int rt711_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), gfp_kernel); + if (!stream) + return -enomem; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == sndrv_pcm_stream_playback) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt711_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, null); + kfree(stream); +} + +static int rt711_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + unsigned int val = 0; + + dev_dbg(dai->dev, "%s %s", __func__, dai->name); + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -einval; + + if (!rt711->slave) + return -einval; + + /* soundwire specific configuration */ + if (substream->stream == sndrv_pcm_stream_playback) { + direction = sdw_data_dir_rx; + port = 3; + } else { + direction = sdw_data_dir_tx; + if (dai->id == rt711_aif1) + port = 4; + else if (dai->id == rt711_aif2) + port = 2; + else + return -einval; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt711->slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "unable to configure port "); + return retval; + } + + if (params_channels(params) <= 16) { + /* bit 3:0 number of channel */ + val |= (params_channels(params) - 1); + } else { + dev_err(component->dev, "unsupported channels %d ", + params_channels(params)); + return -einval; + } + + switch (params_width(params)) { + /* bit 6:4 bits per sample */ + case 8: + break; + case 16: + val |= (0x1 << 4); + break; + case 20: + val |= (0x2 << 4); + break; + case 24: + val |= (0x3 << 4); + break; + case 32: + val |= (0x4 << 4); + break; + default: + return -einval; + } + + /* 48khz */ + regmap_write(rt711->regmap, rt711_dac_format_h, val); + regmap_write(rt711->regmap, rt711_adc1_format_h, val); + regmap_write(rt711->regmap, rt711_adc2_format_h, val); + + return retval; +} + +static int rt711_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt711->slave) + return -einval; + + sdw_stream_remove_slave(rt711->slave, stream->sdw_stream); + return 0; +} + +#define rt711_stereo_rates (sndrv_pcm_rate_44100 | sndrv_pcm_rate_48000) +#define rt711_formats (sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s20_3le | \ + sndrv_pcm_fmtbit_s24_le | sndrv_pcm_fmtbit_s8) + +static struct snd_soc_dai_ops rt711_ops = { + .hw_params = rt711_pcm_hw_params, + .hw_free = rt711_pcm_hw_free, + .set_sdw_stream = rt711_set_sdw_stream, + .shutdown = rt711_shutdown, +}; + +static struct snd_soc_dai_driver rt711_dai[] = { + { + .name = "rt711-aif1", + .id = rt711_aif1, + .playback = { + .stream_name = "dp3 playback", + .channels_min = 1, + .channels_max = 2, + .rates = rt711_stereo_rates, + .formats = rt711_formats, + }, + .capture = { + .stream_name = "dp4 capture", + .channels_min = 1, + .channels_max = 2, + .rates = rt711_stereo_rates, + .formats = rt711_formats, + }, + .ops = &rt711_ops, + }, + { + .name = "rt711-aif2", + .id = rt711_aif2, + .capture = { + .stream_name = "dp2 capture", + .channels_min = 1, + .channels_max = 2, + .rates = rt711_stereo_rates, + .formats = rt711_formats, + }, + .ops = &rt711_ops, + } +}; + +/* bus clock frequency */ +#define rt711_clk_freq_9600000hz 9600000 +#define rt711_clk_freq_12000000hz 12000000 +#define rt711_clk_freq_6000000hz 6000000 +#define rt711_clk_freq_4800000hz 4800000 +#define rt711_clk_freq_2400000hz 2400000 +#define rt711_clk_freq_12288000hz 12288000 + +int rt711_clock_config(struct device *dev) +{ + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt711->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case rt711_clk_freq_12000000hz: + value = 0x0; + break; + case rt711_clk_freq_6000000hz: + value = 0x1; + break; + case rt711_clk_freq_9600000hz: + value = 0x2; + break; + case rt711_clk_freq_4800000hz: + value = 0x3; + break; + case rt711_clk_freq_2400000hz: + value = 0x4; + break; + case rt711_clk_freq_12288000hz: + value = 0x5; + break; + default: + return -einval; + } + + regmap_write(rt711->regmap, 0xe0, value); + regmap_write(rt711->regmap, 0xf0, value); + + dev_dbg(dev, "%s complete, clk_freq=%d ", __func__, clk_freq); + + return 0; +} + +static void rt711_calibration_work(struct work_struct *work) +{ + struct rt711_priv *rt711 = + container_of(work, struct rt711_priv, calibration_work); + + rt711_calibration(rt711); +} + +int rt711_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave) +{ + struct rt711_priv *rt711; + int ret; + + rt711 = devm_kzalloc(dev, sizeof(*rt711), gfp_kernel); + if (!rt711) + return -enomem; + + dev_set_drvdata(dev, rt711); + rt711->slave = slave; + rt711->sdw_regmap = sdw_regmap; + rt711->regmap = regmap; + + /* + * mark hw_init to false + * hw init will be performed when device reports present + */ + rt711->hw_init = false; + rt711->first_hw_init = false; + + /* jd source uses jd2 in default */ + rt711->jd_src = rt711_jd2; + + ret = devm_snd_soc_register_component(dev, + &soc_codec_dev_rt711, + rt711_dai, + array_size(rt711_dai)); + + dev_dbg(&slave->dev, "%s ", __func__); + + return ret; +} + +int rt711_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt711_priv *rt711 = dev_get_drvdata(dev); + + if (rt711->hw_init) + return 0; + + if (rt711->first_hw_init) { + regcache_cache_only(rt711->regmap, false); + regcache_cache_bypass(rt711->regmap, true); + } + + /* + * pm runtime is only enabled when a slave reports as attached + */ + if (!rt711->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + rt711_reset(rt711->regmap); + + /* power on */ + regmap_write(rt711->regmap, rt711_set_audio_power_state, ac_pwrst_d0); + + /* set pin widget */ + regmap_write(rt711->regmap, rt711_set_pin_mic2, 0x25); + regmap_write(rt711->regmap, rt711_set_pin_hp, 0xc0); + regmap_write(rt711->regmap, rt711_set_pin_dmic1, 0x20); + regmap_write(rt711->regmap, rt711_set_pin_dmic2, 0x20); + regmap_write(rt711->regmap, rt711_set_pin_line1, 0x20); + regmap_write(rt711->regmap, rt711_set_pin_line2, 0x20); + + /* mute hp/adc1/adc2 */ + regmap_write(rt711->regmap, rt711_set_gain_hp_h, 0xa080); + regmap_write(rt711->regmap, rt711_set_gain_hp_h, 0x9080); + regmap_write(rt711->regmap, rt711_set_gain_adc2_h, 0x6080); + regmap_write(rt711->regmap, rt711_set_gain_adc2_h, 0x5080); + regmap_write(rt711->regmap, rt711_set_gain_adc1_h, 0x6080); + regmap_write(rt711->regmap, rt711_set_gain_adc1_h, 0x5080); + + /* set configuration default */ + regmap_write(rt711->regmap, 0x4f12, 0x91); + regmap_write(rt711->regmap, 0x4e12, 0xd6); + regmap_write(rt711->regmap, 0x4d12, 0x11); + regmap_write(rt711->regmap, 0x4c12, 0x20); + regmap_write(rt711->regmap, 0x4f13, 0x91); + regmap_write(rt711->regmap, 0x4e13, 0xd6); + regmap_write(rt711->regmap, 0x4d13, 0x11); + regmap_write(rt711->regmap, 0x4c13, 0x21); + regmap_write(rt711->regmap, 0x4c21, 0xf0); + regmap_write(rt711->regmap, 0x4d21, 0x11); + regmap_write(rt711->regmap, 0x4e21, 0x11); + regmap_write(rt711->regmap, 0x4f21, 0x01); + + /* data port arrangement */ + rt711_index_write(rt711->regmap, rt711_vendor_reg, + rt711_tx_rx_mux_ctl, 0x0154); + + /* set index */ + rt711_index_write(rt711->regmap, rt711_vendor_reg, + rt711_digital_misc_ctrl4, 0x201b); + rt711_index_write(rt711->regmap, rt711_vendor_reg, + rt711_combo_jack_auto_ctl1, 0x5089); + rt711_index_write(rt711->regmap, rt711_vendor_reg, + rt711_vrefout_ctl, 0x5064); + rt711_index_write(rt711->regmap, rt711_vendor_reg, + rt711_inline_cmd_ctl, 0xd249); + + /* finish initial settings, set power to d3 */ + regmap_write(rt711->regmap, rt711_set_audio_power_state, ac_pwrst_d3); + + if (rt711->first_hw_init) + rt711_calibration(rt711); + else { + init_delayed_work(&rt711->jack_detect_work, + rt711_jack_detect_handler); + init_delayed_work(&rt711->jack_btn_check_work, + rt711_btn_check_handler); + mutex_init(&rt711->calibrate_mutex); + init_work(&rt711->calibration_work, rt711_calibration_work); + schedule_work(&rt711->calibration_work); + } + + /* + * if set_jack callback occurred early than io_init, + * we set up the jack detection function now + */ + if (rt711->hs_jack) + rt711_jack_init(rt711); + + if (rt711->first_hw_init) { + regcache_cache_bypass(rt711->regmap, false); + regcache_mark_dirty(rt711->regmap); + } else + rt711->first_hw_init = true; + + /* mark slave initialization complete */ + rt711->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + dev_dbg(&slave->dev, "%s hw_init complete ", __func__); + return 0; +} + +module_description("asoc rt711 sdw driver"); +module_author("shuming fan <shumingf@realtek.com>"); +module_license("gpl"); diff --git a/sound/soc/codecs/rt711.h b/sound/soc/codecs/rt711.h --- /dev/null +++ b/sound/soc/codecs/rt711.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * rt711.h -- rt711 alsa soc audio driver header + * + * copyright(c) 2019 realtek semiconductor corp. + */ + +#ifndef __rt711_h__ +#define __rt711_h__ + +extern const struct dev_pm_ops rt711_runtime_pm; + +struct rt711_priv { + struct regmap *regmap; + struct regmap *sdw_regmap; + struct snd_soc_component *component; + struct sdw_slave *slave; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; + struct snd_soc_jack *hs_jack; + struct delayed_work jack_detect_work; + struct delayed_work jack_btn_check_work; + struct work_struct calibration_work; + struct mutex calibrate_mutex; /* for headset calibration */ + int jack_type, jd_src; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +/* nid */ +#define rt711_audio_function_group 0x01 +#define rt711_dac_out2 0x03 +#define rt711_adc_in1 0x09 +#define rt711_adc_in2 0x08 +#define rt711_dmic1 0x12 +#define rt711_dmic2 0x13 +#define rt711_mic2 0x19 +#define rt711_line1 0x1a +#define rt711_line2 0x1b +#define rt711_beep 0x1d +#define rt711_vendor_reg 0x20 +#define rt711_hp_out 0x21 +#define rt711_mixer_in1 0x22 +#define rt711_mixer_in2 0x23 +#define rt711_inline_cmd 0x55 +#define rt711_vendor_cali 0x58 +#define rt711_vendor_ims_dre 0x5b + +/* index (nid:20h) */ +#define rt711_dac_dc_cali_ctl1 0x00 +#define rt711_jd_ctl2 0x09 +#define rt711_cc_det1 0x11 +#define rt711_para_verb_ctl 0x1a +#define rt711_combo_jack_auto_ctl1 0x45 +#define rt711_combo_jack_auto_ctl2 0x46 +#define rt711_inline_cmd_ctl 0x48 +#define rt711_digital_misc_ctrl4 0x4a +#define rt711_vrefout_ctl 0x6b +#define rt711_fsm_ctl 0x6f +#define rt711_irq_flag_table1 0x80 +#define rt711_irq_flag_table2 0x81 +#define rt711_irq_flag_table3 0x82 +#define rt711_tx_rx_mux_ctl 0x91 + +/* index (nid:5bh) */ +#define rt711_ims_digital_ctl1 0x00 +#define rt711_hp_ims_result_l 0x20 +#define rt711_hp_ims_result_r 0x21 + +/* verb */ +#define rt711_verb_set_connect_sel 0x3100 +#define rt711_verb_set_eapd_btlenable 0x3c00 +#define rt711_verb_get_connect_sel 0xb100 +#define rt711_verb_set_power_state 0x3500 +#define rt711_verb_set_channel_streamid 0x3600 +#define rt711_verb_set_pin_widget_control 0x3700 +#define rt711_verb_set_unsolicited_enable 0x3800 +#define rt711_set_amp_gain_mute_h 0x7300 +#define rt711_set_amp_gain_mute_l 0x8380 +#define rt711_verb_get_power_state 0xb500 +#define rt711_verb_get_channel_streamid 0xb600 +#define rt711_verb_get_pin_sense 0xb900 +#define rt711_func_reset 0xff01 + +#define rt711_read_hda_3 0x2012 +#define rt711_read_hda_2 0x2013 +#define rt711_read_hda_1 0x2014 +#define rt711_read_hda_0 0x2015 +#define rt711_priv_index_w_h 0x7500 +#define rt711_priv_index_w_l 0x8580 +#define rt711_priv_data_w_h 0x7400 +#define rt711_priv_data_w_l 0x8480 +#define rt711_priv_index_r_h 0x9d00 +#define rt711_priv_index_r_l 0xad80 +#define rt711_priv_data_r_h 0x9c00 +#define rt711_priv_data_r_l 0xac80 +#define rt711_dac_format_h 0x7203 +#define rt711_dac_format_l 0x8283 +#define rt711_adc1_format_h 0x7209 +#define rt711_adc1_format_l 0x8289 +#define rt711_adc2_format_h 0x7208 +#define rt711_adc2_format_l 0x8288 + +#define rt711_set_audio_power_state\ + (rt711_verb_set_power_state | rt711_audio_function_group) +#define rt711_get_audio_power_state\ + (rt711_verb_get_power_state | rt711_audio_function_group) +#define rt711_set_pin_dmic1\ + (rt711_verb_set_pin_widget_control | rt711_dmic1) +#define rt711_set_pin_dmic2\ + (rt711_verb_set_pin_widget_control | rt711_dmic2) +#define rt711_set_pin_hp\ + (rt711_verb_set_pin_widget_control | rt711_hp_out) +#define rt711_set_pin_mic2\ + (rt711_verb_set_pin_widget_control | rt711_mic2) +#define rt711_set_pin_line1\ + (rt711_verb_set_pin_widget_control | rt711_line1) +#define rt711_set_pin_line2\ + (rt711_verb_set_pin_widget_control | rt711_line2) +#define rt711_set_mic2_unsolicited_enable\ + (rt711_verb_set_unsolicited_enable | rt711_mic2) +#define rt711_set_hp_unsolicited_enable\ + (rt711_verb_set_unsolicited_enable | rt711_hp_out) +#define rt711_set_inline_unsolicited_enable\ + (rt711_verb_set_unsolicited_enable | rt711_inline_cmd) +#define rt711_set_streamid_dac2\ + (rt711_verb_set_channel_streamid | rt711_dac_out2) +#define rt711_set_streamid_adc1\ + (rt711_verb_set_channel_streamid | rt711_adc_in1) +#define rt711_set_streamid_adc2\ + (rt711_verb_set_channel_streamid | rt711_adc_in2) +#define rt711_get_streamid_dac2\ + (rt711_verb_get_channel_streamid | rt711_dac_out2) +#define rt711_get_streamid_adc1\ + (rt711_verb_get_channel_streamid | rt711_adc_in1) +#define rt711_get_streamid_adc2\ + (rt711_verb_get_channel_streamid | rt711_adc_in2) +#define rt711_set_gain_dac2_l\ + (rt711_set_amp_gain_mute_l | rt711_dac_out2) +#define rt711_set_gain_dac2_h\ + (rt711_set_amp_gain_mute_h | rt711_dac_out2) +#define rt711_set_gain_adc1_l\ + (rt711_set_amp_gain_mute_l | rt711_adc_in1) +#define rt711_set_gain_adc1_h\ + (rt711_set_amp_gain_mute_h | rt711_adc_in1) +#define rt711_set_gain_adc2_l\ + (rt711_set_amp_gain_mute_l | rt711_adc_in2) +#define rt711_set_gain_adc2_h\ + (rt711_set_amp_gain_mute_h | rt711_adc_in2) +#define rt711_set_gain_amic_l\ + (rt711_set_amp_gain_mute_l | rt711_mic2) +#define rt711_set_gain_amic_h\ + (rt711_set_amp_gain_mute_h | rt711_mic2) +#define rt711_set_gain_dmic1_l\ + (rt711_set_amp_gain_mute_l | rt711_dmic1) +#define rt711_set_gain_dmic1_h\ + (rt711_set_amp_gain_mute_h | rt711_dmic1) +#define rt711_set_gain_dmic2_l\ + (rt711_set_amp_gain_mute_l | rt711_dmic2) +#define rt711_set_gain_dmic2_h\ + (rt711_set_amp_gain_mute_h | rt711_dmic2) +#define rt711_set_gain_hp_l\ + (rt711_set_amp_gain_mute_l | rt711_hp_out) +#define rt711_set_gain_hp_h\ + (rt711_set_amp_gain_mute_h | rt711_hp_out) + +/* dac dc offset calibration control-1 (0x00)(nid:20h) */ +#define rt711_dac_dc_cali_trigger (0x1 << 15) + +/* jack detect control 2 (0x09)(nid:20h) */ +#define rt711_jd2_2port_200k_decode_hp (0x1 << 13) +#define rt711_hp_jd_sel_jd1 (0x0 << 1) +#define rt711_hp_jd_sel_jd2 (0x1 << 1) + +/* cc det1 (0x11)(nid:20h) */ +#define rt711_hp_jd_final_result_ctl_jd12 (0x1 << 10) +#define rt711_hp_jd_final_result_ctl_ccdet (0x0 << 10) + +/* parameter & verb control (0x1a)(nid:20h) */ +#define rt711_hidden_reg_sw_reset (0x1 << 14) + +/* combo jack auto switch control 2 (0x46)(nid:20h) */ +#define rt711_combojack_auto_det_status (0x1 << 11) +#define rt711_combojack_auto_det_trs (0x1 << 10) +#define rt711_combojack_auto_det_ctia (0x1 << 9) +#define rt711_combojack_auto_det_omtp (0x1 << 8) + +/* fsm control (0x6f)(nid:20h) */ +#define rt711_cali_ctl (0x0 << 0) +#define rt711_combojack_ctl (0x1 << 0) +#define rt711_ims_ctl (0x2 << 0) +#define rt711_depop_ctl (0x3 << 0) + +/* impedance sense digital control 1 (0x00)(nid:5bh) */ +#define rt711_trigger_ims (0x1 << 15) +#define rt711_ims_en (0x1 << 6) + +#define rt711_eapd_high 0x2 +#define rt711_eapd_low 0x0 +#define rt711_mute_sft 7 +/* set input/output mapping to payload[14][15] separately */ +#define rt711_dir_in_sft 6 +#define rt711_dir_out_sft 7 + +enum { + rt711_aif1, + rt711_aif2, + rt711_aifs, +}; + +enum rt711_jd_src { + rt711_jd_null, + rt711_jd1, + rt711_jd2 +}; + +int rt711_io_init(struct device *dev, struct sdw_slave *slave); +int rt711_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave); + +int rt711_jack_detect(struct rt711_priv *rt711, bool *hp, bool *mic); +int rt711_clock_config(struct device *dev); +#endif /* __rt711_h__ */
Audio
320b8b0d13b81f3697acff5b6ddb47f88a09c118
shuming fan pierre louis bossart pierre louis bossart linux intel com
sound
soc
codecs
asoc: rt715: add rt715 codec driver
signed-off-by: jack yu <jack.yu@realtek.com> link: https://lore.kernel.org/r/20200110021821.17843-1-jack.yu@realtek.com signed-off-by: mark brown <broonie@kernel.org>
this release adds wireguard, an fast and secure vpn design that aims to replace other vpns; initial support for usb 4; support for time namespaces; asynchronous ssd trimming in btrfs; initial merge of the multipath tcp support; support for virtualbox guest shared folders; a simple file system to expose the zones of zoned storage devices as files; boot-time tracing, which lets to trace the boot-time process with all the features of ftrace; and bootconfig, created to configure boot-time tracing, which lets to extend the command line in a file attached to initrds. as always, there are many other new drivers and improvements.
add rt715 codec driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'power management', 'cryptography', 'security', 'networking', 'architectures x86 s390 riscv mips powerpc csky microblaze sparc uml arc']
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'device voltage and frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'hardware random number generator (hwrng)', 'cryptography hardware acceleration', 'pci', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'various']
['asoc ', 'rt715']
['c', 'kconfig', 'makefile', 'h']
6
2,056
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + select snd_soc_rt715_sdw if soundwire +config snd_soc_rt715 + tristate + +config snd_soc_rt715_sdw + tristate "realtek rt715 codec - sdw" + depends on soundwire + select snd_soc_rt715 + select regmap_soundwire + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-rt715-objs := rt715.o rt715-sdw.o +obj-$(config_snd_soc_rt715) += snd-soc-rt715.o diff --git a/sound/soc/codecs/rt715-sdw.c b/sound/soc/codecs/rt715-sdw.c --- /dev/null +++ b/sound/soc/codecs/rt715-sdw.c +// spdx-license-identifier: gpl-2.0 +/* + * rt715-sdw.c -- rt715 alsa soc audio driver + * + * copyright(c) 2019 realtek semiconductor corp. + * + * alc715 asoc codec driver based intel dummy sdw codec driver + * + */ +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/soundwire/sdw.h> +#include <linux/soundwire/sdw_type.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/regmap.h> +#include <sound/soc.h> +#include "rt715.h" +#include "rt715-sdw.h" + +static bool rt715_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0 ... 0x00e5: + case 0x00ee ... 0x00ef: + case 0x00f0 ... 0x00f5: + case 0x00fe ... 0x00ff: + case 0x02e0: + case 0x02f0: + case 0x04e0: + case 0x04f0: + case 0x06e0: + case 0x06f0: + case 0x2000 ... 0x2016: + case 0x201a ... 0x2027: + case 0x2029 ... 0x202a: + case 0x202d ... 0x2034: + case 0x2200 ... 0x2204: + case 0x2206 ... 0x2212: + case 0x2220 ... 0x2223: + case 0x2230 ... 0x2239: + case 0x22f0 ... 0x22f3: + case 0x3122: + case 0x3123: + case 0x3124: + case 0x3125: + case 0x3607: + case 0x3608: + case 0x3609: + case 0x3610: + case 0x3611: + case 0x3627: + case 0x3712: + case 0x3713: + case 0x3718: + case 0x3719: + case 0x371a: + case 0x371b: + case 0x371d: + case 0x3729: + case 0x385e: + case 0x3859: + case 0x4c12: + case 0x4c13: + case 0x4c1d: + case 0x4c29: + case 0x4d12: + case 0x4d13: + case 0x4d1d: + case 0x4d29: + case 0x4e12: + case 0x4e13: + case 0x4e1d: + case 0x4e29: + case 0x4f12: + case 0x4f13: + case 0x4f1d: + case 0x4f29: + case 0x7207: + case 0x7208: + case 0x7209: + case 0x7227: + case 0x7307: + case 0x7308: + case 0x7309: + case 0x7312: + case 0x7313: + case 0x7318: + case 0x7319: + case 0x731a: + case 0x731b: + case 0x731d: + case 0x7327: + case 0x7329: + case 0x8287: + case 0x8288: + case 0x8289: + case 0x82a7: + case 0x8387: + case 0x8388: + case 0x8389: + case 0x8392: + case 0x8393: + case 0x8398: + case 0x8399: + case 0x839a: + case 0x839b: + case 0x839d: + case 0x83a7: + case 0x83a9: + case 0x752039: + return true; + default: + return false; + } +} + +static bool rt715_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e5: + case 0x00f0: + case 0x00f3: + case 0x00f5: + case 0x2009: + case 0x2016: + case 0x201b: + case 0x201c: + case 0x201d: + case 0x201f: + case 0x2023: + case 0x2230: + case 0x200b ... 0x200e: /* i2c read */ + case 0x2012 ... 0x2015: /* hd-a read */ + case 0x202d ... 0x202f: /* bra */ + case 0x2201 ... 0x2212: /* i2c debug */ + case 0x2220 ... 0x2223: /* decoded hd-a */ + return true; + default: + return false; + } +} + +static int rt715_sdw_read(void *context, unsigned int reg, unsigned int *val) +{ + struct device *dev = context; + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned int sdw_data_3, sdw_data_2, sdw_data_1, sdw_data_0; + unsigned int reg2 = 0, reg3 = 0, reg4 = 0, mask, nid, val2; + unsigned int is_hda_reg = 1, is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt715->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = rt715_priv_data_r_h | nid; + ret = regmap_write(rt715->sdw_regmap, reg3, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg4, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x3000) { + reg += 0x8000; + ret = regmap_write(rt715->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + reg += 0x2000; + reg |= 0x800; + ret = regmap_write(rt715->sdw_regmap, reg, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for r channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt715->sdw_regmap, reg, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x9000) { + ret = regmap_write(rt715->sdw_regmap, reg, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0xb000) { + ret = regmap_write(rt715->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else { + ret = regmap_read(rt715->sdw_regmap, reg, val); + if (ret < 0) + return ret; + is_hda_reg = 0; + } + + if (is_hda_reg || is_index_reg) { + sdw_data_3 = 0; + sdw_data_2 = 0; + sdw_data_1 = 0; + sdw_data_0 = 0; + ret = regmap_read(rt715->sdw_regmap, rt715_read_hda_3, + &sdw_data_3); + if (ret < 0) + return ret; + ret = regmap_read(rt715->sdw_regmap, rt715_read_hda_2, + &sdw_data_2); + if (ret < 0) + return ret; + ret = regmap_read(rt715->sdw_regmap, rt715_read_hda_1, + &sdw_data_1); + if (ret < 0) + return ret; + ret = regmap_read(rt715->sdw_regmap, rt715_read_hda_0, + &sdw_data_0); + if (ret < 0) + return ret; + *val = ((sdw_data_3 & 0xff) << 24) | + ((sdw_data_2 & 0xff) << 16) | + ((sdw_data_1 & 0xff) << 8) | (sdw_data_0 & 0xff); + } + + if (is_hda_reg == 0) + dev_dbg(dev, "[%s] %04x => %08x ", __func__, reg, *val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x => %08x ", __func__, + reg, reg2, reg3, reg4, *val); + else + dev_dbg(dev, "[%s] %04x %04x => %08x ", + __func__, reg, reg2, *val); + + return 0; +} + +static int rt715_sdw_write(void *context, unsigned int reg, unsigned int val) +{ + struct device *dev = context; + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned int reg2 = 0, reg3, reg4, nid, mask, val2; + unsigned int is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt715->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = rt715_priv_data_w_h | nid; + ret = regmap_write(rt715->sdw_regmap, reg3, + ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg4, (val & 0xff)); + if (ret < 0) + return ret; + is_index_reg = 1; + } else if (reg < 0x4fff) { + ret = regmap_write(rt715->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (reg == rt715_func_reset) { + ret = regmap_write(rt715->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + ret = regmap_write(rt715->sdw_regmap, reg, + ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, (val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for r channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, + ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt715->sdw_regmap, reg, (val & 0xff)); + if (ret < 0) + return ret; + } + + if (reg2 == 0) + dev_dbg(dev, "[%s] %04x <= %04x ", __func__, reg, val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x <= %04x %04x ", + __func__, reg, reg2, reg3, reg4, val2, val); + else + dev_dbg(dev, "[%s] %04x %04x <= %04x ", + __func__, reg, reg2, val); + + return 0; +} + +static const struct regmap_config rt715_regmap = { + .reg_bits = 24, + .val_bits = 32, + .readable_reg = rt715_readable_register, /* readable registers */ + .volatile_reg = rt715_volatile_register, /* volatile register */ + .max_register = 0x752039, /* maximum number of register */ + .reg_defaults = rt715_reg_defaults, /* defaults */ + .num_reg_defaults = array_size(rt715_reg_defaults), + .cache_type = regcache_rbtree, + .use_single_read = true, + .use_single_write = true, + .reg_read = rt715_sdw_read, + .reg_write = rt715_sdw_write, +}; + +static const struct regmap_config rt715_sdw_regmap = { + .name = "sdw", + .reg_bits = 32, /* total register space for sdw */ + .val_bits = 8, /* total number of bits in register */ + .max_register = 0xff01, /* maximum number of register */ + .cache_type = regcache_none, + .use_single_read = true, + .use_single_write = true, +}; + +int hda_to_sdw(unsigned int nid, unsigned int verb, unsigned int payload, + unsigned int *sdw_addr_h, unsigned int *sdw_data_h, + unsigned int *sdw_addr_l, unsigned int *sdw_data_l) +{ + unsigned int offset_h, offset_l, e_verb; + + if (((verb & 0xff) != 0) || verb == 0xf00) { /* 12 bits command */ + if (verb == 0x7ff) /* special case */ + offset_h = 0; + else + offset_h = 0x3000; + + if (verb & 0x800) /* get command */ + e_verb = (verb - 0xf00) | 0x80; + else /* set command */ + e_verb = (verb - 0x700); + + *sdw_data_h = payload; /* 7 bits payload */ + *sdw_addr_l = *sdw_data_l = 0; + } else { /* 4 bits command */ + if ((verb & 0x800) == 0x800) { /* read */ + offset_h = 0x9000; + offset_l = 0xa000; + } else { /* write */ + offset_h = 0x7000; + offset_l = 0x8000; + } + e_verb = verb >> 8; + *sdw_data_h = (payload >> 8); /* 16 bits payload [15:8] */ + *sdw_addr_l = (e_verb << 8) | nid | 0x80; /* 0x80: valid bit */ + *sdw_addr_l += offset_l; + *sdw_data_l = payload & 0xff; + } + + *sdw_addr_h = (e_verb << 8) | nid; + *sdw_addr_h += offset_h; + + return 0; +} +export_symbol(hda_to_sdw); + +static int rt715_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt715_priv *rt715 = dev_get_drvdata(&slave->dev); + + /* update the status */ + rt715->status = status; + /* + * perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt715->hw_init || rt715->status != sdw_slave_attached) + return 0; + + /* perform i/o transfers required for slave initialization */ + return rt715_io_init(&slave->dev, slave); +} + +static int rt715_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = false; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x50;/* bitmap: 01010000 */ + prop->sink_ports = 0x0; /* bitmap: 00000000 */ + + nval = hweight32(prop->source_ports); + num_of_ports += nval; + prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->src_dpn_prop), + gfp_kernel); + if (!prop->src_dpn_prop) + return -enomem; + + dpn = prop->src_dpn_prop; + i = 0; + addr = prop->source_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* do this again for sink now */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + gfp_kernel); + if (!prop->sink_dpn_prop) + return -enomem; + + dpn = prop->sink_dpn_prop; + i = 0; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + gfp_kernel); + if (!slave->port_ready) + return -enomem; + + /* initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + /* wake-up event */ + prop->wake_capable = 1; + + return 0; +} + +static int rt715_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt715_priv *rt715 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt715->params, params, sizeof(*params)); + + ret = rt715_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "invalid clk config"); + + return 0; +} + +static struct sdw_slave_ops rt715_slave_ops = { + .read_prop = rt715_read_prop, + .update_status = rt715_update_status, + .bus_config = rt715_bus_config, +}; + +static int rt715_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *sdw_regmap, *regmap; + + /* assign ops */ + slave->ops = &rt715_slave_ops; + + /* regmap initialization */ + sdw_regmap = devm_regmap_init_sdw(slave, &rt715_sdw_regmap); + if (!sdw_regmap) + return -einval; + + regmap = devm_regmap_init(&slave->dev, null, &slave->dev, + &rt715_regmap); + if (!regmap) + return -einval; + + rt715_init(&slave->dev, sdw_regmap, regmap, slave); + + return 0; +} + +static const struct sdw_device_id rt715_id[] = { + sdw_slave_entry(0x025d, 0x715, 0), + {}, +}; +module_device_table(sdw, rt715_id); + +static int rt715_dev_suspend(struct device *dev) +{ + struct rt715_priv *rt715 = dev_get_drvdata(dev); + + if (!rt715->hw_init) + return 0; + + regcache_cache_only(rt715->regmap, true); + + return 0; +} + +#define rt715_probe_timeout 2000 + +static int rt715_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = to_sdw_slave_device(dev); + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt715->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(rt715_probe_timeout)); + if (!time) { + dev_err(&slave->dev, "initialization not complete, timed out "); + return -etimedout; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt715->regmap, false); + regcache_sync_region(rt715->regmap, 0x3000, 0x8fff); + regcache_sync_region(rt715->regmap, 0x752039, 0x752039); + + return 0; +} + +static const struct dev_pm_ops rt715_pm = { + set_system_sleep_pm_ops(rt715_dev_suspend, rt715_dev_resume) + set_runtime_pm_ops(rt715_dev_suspend, rt715_dev_resume, null) +}; + +static struct sdw_driver rt715_sdw_driver = { + .driver = { + .name = "rt715", + .owner = this_module, + .pm = &rt715_pm, + }, + .probe = rt715_sdw_probe, + .ops = &rt715_slave_ops, + .id_table = rt715_id, +}; +module_sdw_driver(rt715_sdw_driver); + +module_description("asoc rt715 driver sdw"); +module_author("jack yu <jack.yu@realtek.com>"); +module_license("gpl v2"); diff --git a/sound/soc/codecs/rt715-sdw.h b/sound/soc/codecs/rt715-sdw.h --- /dev/null +++ b/sound/soc/codecs/rt715-sdw.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * rt715-sdw.h -- rt715 alsa soc audio driver header + * + * copyright(c) 2019 realtek semiconductor corp. + */ + +#ifndef __rt715_sdw_h__ +#define __rt715_sdw_h__ + +static const struct reg_default rt715_reg_defaults[] = { + { 0x0000, 0x00 }, + { 0x0001, 0x00 }, + { 0x0002, 0x00 }, + { 0x0003, 0x00 }, + { 0x0004, 0x00 }, + { 0x0005, 0x01 }, + { 0x0020, 0x00 }, + { 0x0022, 0x00 }, + { 0x0023, 0x00 }, + { 0x0024, 0x00 }, + { 0x0025, 0x00 }, + { 0x0026, 0x00 }, + { 0x0030, 0x00 }, + { 0x0032, 0x00 }, + { 0x0033, 0x00 }, + { 0x0034, 0x00 }, + { 0x0035, 0x00 }, + { 0x0036, 0x00 }, + { 0x0040, 0x00 }, + { 0x0041, 0x00 }, + { 0x0042, 0x00 }, + { 0x0043, 0x00 }, + { 0x0044, 0x20 }, + { 0x0045, 0x01 }, + { 0x0046, 0x00 }, + { 0x0050, 0x20 }, + { 0x0051, 0x02 }, + { 0x0052, 0x5d }, + { 0x0053, 0x07 }, + { 0x0054, 0x15 }, + { 0x0055, 0x00 }, + { 0x0060, 0x00 }, + { 0x0070, 0x00 }, + { 0x0080, 0x00 }, + { 0x0088, 0x10 }, + { 0x00e0, 0x00 }, + { 0x00e1, 0x00 }, + { 0x00e2, 0x00 }, + { 0x00e3, 0x00 }, + { 0x00e4, 0x00 }, + { 0x00e5, 0x00 }, + { 0x00ee, 0x00 }, + { 0x00ef, 0x00 }, + { 0x00f0, 0x00 }, + { 0x00f1, 0x00 }, + { 0x00f2, 0x00 }, + { 0x00f3, 0x00 }, + { 0x00f4, 0x00 }, + { 0x00f5, 0x00 }, + { 0x00fe, 0x00 }, + { 0x00ff, 0x00 }, + { 0x0200, 0x00 }, + { 0x0201, 0x00 }, + { 0x0202, 0x20 }, + { 0x0203, 0x00 }, + { 0x0204, 0x00 }, + { 0x0205, 0x03 }, + { 0x0220, 0x00 }, + { 0x0221, 0x00 }, + { 0x0222, 0x00 }, + { 0x0223, 0x00 }, + { 0x0224, 0x00 }, + { 0x0225, 0x00 }, + { 0x0226, 0x00 }, + { 0x0227, 0x00 }, + { 0x0230, 0x00 }, + { 0x0231, 0x00 }, + { 0x0232, 0x00 }, + { 0x0233, 0x00 }, + { 0x0234, 0x00 }, + { 0x0235, 0x00 }, + { 0x0236, 0x00 }, + { 0x0237, 0x00 }, + { 0x02e0, 0x00 }, + { 0x02f0, 0x00 }, + { 0x0400, 0x00 }, + { 0x0401, 0x00 }, + { 0x0402, 0x20 }, + { 0x0403, 0x00 }, + { 0x0404, 0x00 }, + { 0x0405, 0x0f }, + { 0x0420, 0x00 }, + { 0x0421, 0x00 }, + { 0x0422, 0x00 }, + { 0x0423, 0x00 }, + { 0x0424, 0x00 }, + { 0x0425, 0x00 }, + { 0x0426, 0x00 }, + { 0x0427, 0x00 }, + { 0x0430, 0x00 }, + { 0x0431, 0x00 }, + { 0x0432, 0x00 }, + { 0x0433, 0x00 }, + { 0x0434, 0x00 }, + { 0x0435, 0x00 }, + { 0x0436, 0x00 }, + { 0x0437, 0x00 }, + { 0x04e0, 0x00 }, + { 0x04f0, 0x00 }, + { 0x0600, 0x00 }, + { 0x0601, 0x00 }, + { 0x0602, 0x20 }, + { 0x0603, 0x00 }, + { 0x0604, 0x00 }, + { 0x0605, 0xff }, + { 0x0620, 0x00 }, + { 0x0621, 0x00 }, + { 0x0622, 0x00 }, + { 0x0623, 0x00 }, + { 0x0624, 0x00 }, + { 0x0625, 0x00 }, + { 0x0626, 0x00 }, + { 0x0627, 0x00 }, + { 0x0630, 0x00 }, + { 0x0631, 0x00 }, + { 0x0632, 0x00 }, + { 0x0633, 0x00 }, + { 0x0634, 0x00 }, + { 0x0635, 0x00 }, + { 0x0636, 0x00 }, + { 0x0637, 0x00 }, + { 0x06e0, 0x00 }, + { 0x06f0, 0x00 }, + { 0x0f00, 0x00 }, + { 0x0f01, 0x00 }, + { 0x0f02, 0x00 }, + { 0x0f03, 0x00 }, + { 0x0f04, 0x00 }, + { 0x0f05, 0xff }, + { 0x0f06, 0x00 }, + { 0x0f07, 0x00 }, + { 0x0f08, 0x00 }, + { 0x0f09, 0x00 }, + { 0x0f0a, 0x00 }, + { 0x0f0b, 0x00 }, + { 0x0f0c, 0x00 }, + { 0x0f0d, 0x00 }, + { 0x0f0e, 0x00 }, + { 0x0f0f, 0x00 }, + { 0x0f10, 0x00 }, + { 0x0f11, 0x00 }, + { 0x0f12, 0x00 }, + { 0x0f13, 0x00 }, + { 0x0f14, 0x00 }, + { 0x0f15, 0x00 }, + { 0x0f16, 0x00 }, + { 0x0f17, 0x00 }, + { 0x0f18, 0x00 }, + { 0x0f19, 0x00 }, + { 0x0f1a, 0x00 }, + { 0x0f1b, 0x00 }, + { 0x0f1c, 0x00 }, + { 0x0f1d, 0x00 }, + { 0x0f1e, 0x00 }, + { 0x0f1f, 0x00 }, + { 0x0f20, 0x00 }, + { 0x0f21, 0x00 }, + { 0x0f22, 0x00 }, + { 0x0f23, 0x00 }, + { 0x0f24, 0x00 }, + { 0x0f25, 0x00 }, + { 0x0f26, 0x00 }, + { 0x0f27, 0x00 }, + { 0x0f30, 0x00 }, + { 0x0f31, 0x00 }, + { 0x0f32, 0x00 }, + { 0x0f33, 0x00 }, + { 0x0f34, 0x00 }, + { 0x0f35, 0x00 }, + { 0x0f36, 0x00 }, + { 0x0f37, 0x00 }, + { 0x2000, 0x00 }, + { 0x2001, 0x00 }, + { 0x2002, 0x00 }, + { 0x2003, 0x00 }, + { 0x2004, 0x00 }, + { 0x2005, 0x00 }, + { 0x2006, 0x00 }, + { 0x2007, 0x00 }, + { 0x2008, 0x00 }, + { 0x2009, 0x03 }, + { 0x200a, 0x00 }, + { 0x200b, 0x00 }, + { 0x200c, 0x00 }, + { 0x200d, 0x00 }, + { 0x200e, 0x00 }, + { 0x200f, 0x10 }, + { 0x2010, 0x00 }, + { 0x2011, 0x00 }, + { 0x2012, 0x00 }, + { 0x2013, 0x00 }, + { 0x2014, 0x00 }, + { 0x2015, 0x00 }, + { 0x2016, 0x00 }, + { 0x201a, 0x00 }, + { 0x201b, 0x00 }, + { 0x201c, 0x00 }, + { 0x201d, 0x00 }, + { 0x201e, 0x00 }, + { 0x201f, 0x00 }, + { 0x2020, 0x00 }, + { 0x2021, 0x00 }, + { 0x2022, 0x00 }, + { 0x2023, 0x00 }, + { 0x2024, 0x00 }, + { 0x2025, 0x01 }, + { 0x2026, 0x00 }, + { 0x2027, 0x00 }, + { 0x2029, 0x00 }, + { 0x202a, 0x00 }, + { 0x202d, 0x00 }, + { 0x202e, 0x00 }, + { 0x202f, 0x00 }, + { 0x2030, 0x00 }, + { 0x2031, 0x00 }, + { 0x2032, 0x00 }, + { 0x2033, 0x00 }, + { 0x2034, 0x00 }, + { 0x2200, 0x00 }, + { 0x2201, 0x00 }, + { 0x2202, 0x00 }, + { 0x2203, 0x00 }, + { 0x2204, 0x00 }, + { 0x2206, 0x00 }, + { 0x2207, 0x00 }, + { 0x2208, 0x00 }, + { 0x2209, 0x00 }, + { 0x220a, 0x00 }, + { 0x220b, 0x00 }, + { 0x220c, 0x00 }, + { 0x220d, 0x00 }, + { 0x220e, 0x00 }, + { 0x220f, 0x00 }, + { 0x2210, 0x00 }, + { 0x2211, 0x00 }, + { 0x2212, 0x00 }, + { 0x2220, 0x00 }, + { 0x2221, 0x00 }, + { 0x2222, 0x00 }, + { 0x2223, 0x00 }, + { 0x2230, 0x00 }, + { 0x2231, 0x0f }, + { 0x2232, 0x00 }, + { 0x2233, 0x00 }, + { 0x2234, 0x00 }, + { 0x2235, 0x00 }, + { 0x2236, 0x00 }, + { 0x2237, 0x00 }, + { 0x2238, 0x00 }, + { 0x2239, 0x00 }, + { 0x22f0, 0x00 }, + { 0x22f1, 0x00 }, + { 0x22f2, 0x00 }, + { 0x22f3, 0x00 }, + { 0x3122, 0x02 }, + { 0x3123, 0x03 }, + { 0x3124, 0x00 }, + { 0x3125, 0x01 }, + { 0x3607, 0x00 }, + { 0x3608, 0x00 }, + { 0x3609, 0x00 }, + { 0x3610, 0x00 }, + { 0x3611, 0x00 }, + { 0x3627, 0x00 }, + { 0x3712, 0x00 }, + { 0x3713, 0x00 }, + { 0x3718, 0x00 }, + { 0x3719, 0x00 }, + { 0x371a, 0x00 }, + { 0x371b, 0x00 }, + { 0x371d, 0x00 }, + { 0x3729, 0x00 }, + { 0x385e, 0x00 }, + { 0x3859, 0x00 }, + { 0x4c12, 0x411111f0 }, + { 0x4c13, 0x411111f0 }, + { 0x4c1d, 0x411111f0 }, + { 0x4c29, 0x411111f0 }, + { 0x4d12, 0x411111f0 }, + { 0x4d13, 0x411111f0 }, + { 0x4d1d, 0x411111f0 }, + { 0x4d29, 0x411111f0 }, + { 0x4e12, 0x411111f0 }, + { 0x4e13, 0x411111f0 }, + { 0x4e1d, 0x411111f0 }, + { 0x4e29, 0x411111f0 }, + { 0x4f12, 0x411111f0 }, + { 0x4f13, 0x411111f0 }, + { 0x4f1d, 0x411111f0 }, + { 0x4f29, 0x411111f0 }, + { 0x7207, 0x00 }, + { 0x8287, 0x00 }, + { 0x7208, 0x00 }, + { 0x8288, 0x00 }, + { 0x7209, 0x00 }, + { 0x8289, 0x00 }, + { 0x7227, 0x00 }, + { 0x82a7, 0x00 }, + { 0x7307, 0x97 }, + { 0x8387, 0x97 }, + { 0x7308, 0x97 }, + { 0x8388, 0x97 }, + { 0x7309, 0x97 }, + { 0x8389, 0x97 }, + { 0x7312, 0x00 }, + { 0x8392, 0x00 }, + { 0x7313, 0x00 }, + { 0x8393, 0x00 }, + { 0x7318, 0x00 }, + { 0x8398, 0x00 }, + { 0x7319, 0x00 }, + { 0x8399, 0x00 }, + { 0x731a, 0x00 }, + { 0x839a, 0x00 }, + { 0x731b, 0x00 }, + { 0x839b, 0x00 }, + { 0x731d, 0x00 }, + { 0x839d, 0x00 }, + { 0x7327, 0x97 }, + { 0x83a7, 0x97 }, + { 0x7329, 0x00 }, + { 0x83a9, 0x00 }, + { 0x752039, 0xa500 }, +}; + +#endif /* __rt715_h__ */ diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c --- /dev/null +++ b/sound/soc/codecs/rt715.c +// spdx-license-identifier: gpl-2.0 +/* + * rt715.c -- rt715 alsa soc audio driver + * + * copyright(c) 2019 realtek semiconductor corp. + * + * alc715 asoc codec driver based intel dummy sdw codec driver + * + */ + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/pm_runtime.h> +#include <linux/pm.h> +#include <linux/soundwire/sdw.h> +#include <linux/gpio.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/platform_device.h> +#include <linux/regulator/consumer.h> +#include <linux/gpio/consumer.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <linux/of_device.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/initval.h> +#include <sound/tlv.h> +#include <sound/hda_verbs.h> + +#include "rt715.h" + +static int rt715_index_write(struct regmap *regmap, unsigned int reg, + unsigned int value) +{ + int ret; + unsigned int addr = ((rt715_priv_index_w_h) << 8) | reg; + + ret = regmap_write(regmap, addr, value); + if (ret < 0) { + pr_err("failed to set private value: %08x <= %04x %d ", ret, + addr, value); + } + + return ret; +} + +static void rt715_get_gain(struct rt715_priv *rt715, unsigned int addr_h, + unsigned int addr_l, unsigned int val_h, + unsigned int *r_val, unsigned int *l_val) +{ + int ret; + /* r channel */ + *r_val = (val_h << 8); + ret = regmap_read(rt715->regmap, addr_l, r_val); + if (ret < 0) + pr_err("failed to get r channel gain. "); + + /* l channel */ + val_h |= 0x20; + *l_val = (val_h << 8); + ret = regmap_read(rt715->regmap, addr_h, l_val); + if (ret < 0) + pr_err("failed to get l channel gain. "); +} + +/* for verb-set amplifier gain (verb id = 3h) */ +static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + unsigned int addr_h, addr_l, val_h, val_ll, val_lr; + unsigned int read_ll, read_rl; + int i; + + /* can't use update bit function, so read the original value first */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == rt715_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt715_get_gain(rt715, addr_h, addr_l, val_h, &read_rl, &read_ll); + + /* l channel */ + if (mc->invert) { + /* for mute */ + val_ll = (mc->max - ucontrol->value.integer.value[0]) << 7; + /* keep gain */ + read_ll = read_ll & 0x7f; + val_ll |= read_ll; + } else { + /* for gain */ + val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); + if (val_ll > mc->max) + val_ll = mc->max; + /* keep mute status */ + read_ll = read_ll & 0x80; + val_ll |= read_ll; + } + + /* r channel */ + if (mc->invert) { + regmap_write(rt715->regmap, + rt715_set_audio_power_state, ac_pwrst_d0); + /* for mute */ + val_lr = (mc->max - ucontrol->value.integer.value[1]) << 7; + /* keep gain */ + read_rl = read_rl & 0x7f; + val_lr |= read_rl; + } else { + /* for gain */ + val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); + if (val_lr > mc->max) + val_lr = mc->max; + /* keep mute status */ + read_rl = read_rl & 0x80; + val_lr |= read_rl; + } + + for (i = 0; i < 3; i++) { /* retry 3 times at most */ + + if (val_ll == val_lr) { + /* set both l/r channels at the same time */ + val_h = (1 << mc->shift) | (3 << 4); + regmap_write(rt715->regmap, addr_h, + (val_h << 8 | val_ll)); + regmap_write(rt715->regmap, addr_l, + (val_h << 8 | val_ll)); + } else { + /* lch*/ + val_h = (1 << mc->shift) | (1 << 5); + regmap_write(rt715->regmap, addr_h, + (val_h << 8 | val_ll)); + /* rch */ + val_h = (1 << mc->shift) | (1 << 4); + regmap_write(rt715->regmap, addr_l, + (val_h << 8 | val_lr)); + } + /* check result */ + if (mc->shift == rt715_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt715_get_gain(rt715, addr_h, addr_l, val_h, + &read_rl, &read_ll); + if (read_rl == val_lr && read_ll == val_ll) + break; + } + /* d0:power on state, d3: power saving mode */ + if (dapm->bias_level <= snd_soc_bias_standby) + regmap_write(rt715->regmap, + rt715_set_audio_power_state, ac_pwrst_d3); + return 0; +} + +static int rt715_set_amp_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + unsigned int addr_h, addr_l, val_h; + unsigned int read_ll, read_rl; + + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == rt715_dir_out_sft) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt715_get_gain(rt715, addr_h, addr_l, val_h, &read_rl, &read_ll); + + if (mc->invert) { + /* for mute status */ + read_ll = !((read_ll & 0x80) >> rt715_mute_sft); + read_rl = !((read_rl & 0x80) >> rt715_mute_sft); + } else { + /* for gain */ + read_ll = read_ll & 0x7f; + read_rl = read_rl & 0x7f; + } + ucontrol->value.integer.value[0] = read_ll; + ucontrol->value.integer.value[1] = read_rl; + + return 0; +} + +static const declare_tlv_db_scale(out_vol_tlv, -6525, 75, 0); +static const declare_tlv_db_scale(in_vol_tlv, -1725, 75, 0); +static const declare_tlv_db_scale(mic_vol_tlv, 0, 1000, 0); + +#define soc_double_r_ext(xname, reg_left, reg_right, xshift, xmax, xinvert,\ + xhandler_get, xhandler_put) \ +{ .iface = sndrv_ctl_elem_iface_mixer, .name = (xname), \ + .info = snd_soc_info_volsw, \ + .get = xhandler_get, .put = xhandler_put, \ + .private_value = soc_double_r_value(reg_left, reg_right, xshift, \ + xmax, xinvert) } + +static const struct snd_kcontrol_new rt715_snd_controls[] = { + /* capture switch */ + soc_double_r_ext("adc 07 capture switch", rt715_set_gain_mic_adc_h, + rt715_set_gain_mic_adc_l, rt715_dir_in_sft, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + soc_double_r_ext("adc 08 capture switch", rt715_set_gain_line_adc_h, + rt715_set_gain_line_adc_l, rt715_dir_in_sft, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + soc_double_r_ext("adc 09 capture switch", rt715_set_gain_mix_adc_h, + rt715_set_gain_mix_adc_l, rt715_dir_in_sft, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + soc_double_r_ext("adc 27 capture switch", rt715_set_gain_mix_adc2_h, + rt715_set_gain_mix_adc2_l, rt715_dir_in_sft, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + /* volume control */ + soc_double_r_ext_tlv("adc 07 capture volume", rt715_set_gain_mic_adc_h, + rt715_set_gain_mic_adc_l, rt715_dir_in_sft, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + soc_double_r_ext_tlv("adc 08 capture volume", rt715_set_gain_line_adc_h, + rt715_set_gain_line_adc_l, rt715_dir_in_sft, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + soc_double_r_ext_tlv("adc 09 capture volume", rt715_set_gain_mix_adc_h, + rt715_set_gain_mix_adc_l, rt715_dir_in_sft, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + soc_double_r_ext_tlv("adc 27 capture volume", rt715_set_gain_mix_adc2_h, + rt715_set_gain_mix_adc2_l, rt715_dir_in_sft, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + /* mic boost control */ + soc_double_r_ext_tlv("dmic1 boost", rt715_set_gain_dmic1_h, + rt715_set_gain_dmic1_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + soc_double_r_ext_tlv("dmic2 boost", rt715_set_gain_dmic2_h, + rt715_set_gain_dmic2_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + soc_double_r_ext_tlv("dmic3 boost", rt715_set_gain_dmic3_h, + rt715_set_gain_dmic3_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + soc_double_r_ext_tlv("dmic4 boost", rt715_set_gain_dmic4_h, + rt715_set_gain_dmic4_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + soc_double_r_ext_tlv("mic1 boost", rt715_set_gain_mic1_h, + rt715_set_gain_mic1_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + soc_double_r_ext_tlv("mic2 boost", rt715_set_gain_mic2_h, + rt715_set_gain_mic2_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + soc_double_r_ext_tlv("line1 boost", rt715_set_gain_line1_h, + rt715_set_gain_line1_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + soc_double_r_ext_tlv("line2 boost", rt715_set_gain_line2_h, + rt715_set_gain_line2_l, rt715_dir_in_sft, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), +}; + +static int rt715_mux_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int reg, val; + int ret; + + /* nid = e->reg, vid = 0xf01 */ + reg = rt715_verb_set_connect_sel | e->reg; + ret = regmap_read(rt715->regmap, reg, &val); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d ", + __func__, ret); + return ret; + } + + /* + * the first two indices of adc mux 24/25 are routed to the same + * hardware source. ie, adc mux 24 0/1 will both connect to mic2. + * to have a unique set of inputs, we skip the index1 of the muxes. + */ + if ((e->reg == rt715_mux_in3 || e->reg == rt715_mux_in4) && (val > 0)) + val -= 1; + ucontrol->value.enumerated.item[0] = val; + + return 0; +} + +static int rt715_mux_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int *item = ucontrol->value.enumerated.item; + unsigned int val, val2 = 0, change, reg; + int ret; + + if (item[0] >= e->items) + return -einval; + + /* verb id = 0x701h, nid = e->reg */ + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; + + reg = rt715_verb_set_connect_sel | e->reg; + ret = regmap_read(rt715->regmap, reg, &val2); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d ", + __func__, ret); + return ret; + } + + if (val == val2) + change = 0; + else + change = 1; + + if (change) { + reg = rt715_verb_set_connect_sel | e->reg; + regmap_write(rt715->regmap, reg, val); + } + + snd_soc_dapm_mux_update_power(dapm, kcontrol, + item[0], e, null); + + return change; +} + +static const char * const adc_22_23_mux_text[] = { + "mic1", + "mic2", + "line1", + "line2", + "dmic1", + "dmic2", + "dmic3", + "dmic4", +}; + +/** + * due to mux design for nid 24 (mux_in3)/25 (mux_in4), connection index 0 and + * 1 will be connected to the same dmic source, therefore we skip index 1 to + * avoid misunderstanding on usage of dapm routing. + */ +static const unsigned int rt715_adc_24_25_values[] = { + 0, + 2, + 3, + 4, + 5, +}; + +static const char * const adc_24_mux_text[] = { + "mic2", + "dmic1", + "dmic2", + "dmic3", + "dmic4", +}; + +static const char * const adc_25_mux_text[] = { + "mic1", + "dmic1", + "dmic2", + "dmic3", + "dmic4", +}; + +static soc_enum_single_decl( + rt715_adc22_enum, rt715_mux_in1, 0, adc_22_23_mux_text); + +static soc_enum_single_decl( + rt715_adc23_enum, rt715_mux_in2, 0, adc_22_23_mux_text); + +static soc_value_enum_single_decl(rt715_adc24_enum, + rt715_mux_in3, 0, 0xf, + adc_24_mux_text, rt715_adc_24_25_values); +static soc_value_enum_single_decl(rt715_adc25_enum, + rt715_mux_in4, 0, 0xf, + adc_25_mux_text, rt715_adc_24_25_values); + +static const struct snd_kcontrol_new rt715_adc22_mux = + soc_dapm_enum_ext("adc 22 mux", rt715_adc22_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_kcontrol_new rt715_adc23_mux = + soc_dapm_enum_ext("adc 23 mux", rt715_adc23_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_kcontrol_new rt715_adc24_mux = + soc_dapm_enum_ext("adc 24 mux", rt715_adc24_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_kcontrol_new rt715_adc25_mux = + soc_dapm_enum_ext("adc 25 mux", rt715_adc25_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_soc_dapm_widget rt715_dapm_widgets[] = { + snd_soc_dapm_input("dmic1"), + snd_soc_dapm_input("dmic2"), + snd_soc_dapm_input("dmic3"), + snd_soc_dapm_input("dmic4"), + snd_soc_dapm_input("mic1"), + snd_soc_dapm_input("mic2"), + snd_soc_dapm_input("line1"), + snd_soc_dapm_input("line2"), + snd_soc_dapm_adc("adc 07", null, rt715_set_streamid_mic_adc, 4, 0), + snd_soc_dapm_adc("adc 08", null, rt715_set_streamid_line_adc, 4, 0), + snd_soc_dapm_adc("adc 09", null, rt715_set_streamid_mix_adc, 4, 0), + snd_soc_dapm_adc("adc 27", null, rt715_set_streamid_mix_adc2, 4, 0), + snd_soc_dapm_mux("adc 22 mux", snd_soc_nopm, 0, 0, + &rt715_adc22_mux), + snd_soc_dapm_mux("adc 23 mux", snd_soc_nopm, 0, 0, + &rt715_adc23_mux), + snd_soc_dapm_mux("adc 24 mux", snd_soc_nopm, 0, 0, + &rt715_adc24_mux), + snd_soc_dapm_mux("adc 25 mux", snd_soc_nopm, 0, 0, + &rt715_adc25_mux), + snd_soc_dapm_aif_out("dp4tx", "dp4 capture", 0, snd_soc_nopm, 0, 0), + snd_soc_dapm_aif_out("dp6tx", "dp6 capture", 0, snd_soc_nopm, 0, 0), +}; + +static const struct snd_soc_dapm_route rt715_audio_map[] = { + {"dp6tx", null, "adc 09"}, + {"dp6tx", null, "adc 08"}, + {"dp4tx", null, "adc 07"}, + {"dp4tx", null, "adc 27"}, + {"adc 09", null, "adc 22 mux"}, + {"adc 08", null, "adc 23 mux"}, + {"adc 07", null, "adc 24 mux"}, + {"adc 27", null, "adc 25 mux"}, + {"adc 22 mux", "mic1", "mic1"}, + {"adc 22 mux", "mic2", "mic2"}, + {"adc 22 mux", "line1", "line1"}, + {"adc 22 mux", "line2", "line2"}, + {"adc 22 mux", "dmic1", "dmic1"}, + {"adc 22 mux", "dmic2", "dmic2"}, + {"adc 22 mux", "dmic3", "dmic3"}, + {"adc 22 mux", "dmic4", "dmic4"}, + {"adc 23 mux", "mic1", "mic1"}, + {"adc 23 mux", "mic2", "mic2"}, + {"adc 23 mux", "line1", "line1"}, + {"adc 23 mux", "line2", "line2"}, + {"adc 23 mux", "dmic1", "dmic1"}, + {"adc 23 mux", "dmic2", "dmic2"}, + {"adc 23 mux", "dmic3", "dmic3"}, + {"adc 23 mux", "dmic4", "dmic4"}, + {"adc 24 mux", "mic2", "mic2"}, + {"adc 24 mux", "dmic1", "dmic1"}, + {"adc 24 mux", "dmic2", "dmic2"}, + {"adc 24 mux", "dmic3", "dmic3"}, + {"adc 24 mux", "dmic4", "dmic4"}, + {"adc 25 mux", "mic1", "mic1"}, + {"adc 25 mux", "dmic1", "dmic1"}, + {"adc 25 mux", "dmic2", "dmic2"}, + {"adc 25 mux", "dmic3", "dmic3"}, + {"adc 25 mux", "dmic4", "dmic4"}, +}; + +static int rt715_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + + switch (level) { + case snd_soc_bias_prepare: + if (dapm->bias_level == snd_soc_bias_standby) { + regmap_write(rt715->regmap, + rt715_set_audio_power_state, + ac_pwrst_d0); + } + break; + + case snd_soc_bias_standby: + regmap_write(rt715->regmap, + rt715_set_audio_power_state, + ac_pwrst_d3); + break; + + default: + break; + } + dapm->bias_level = level; + return 0; +} + +static const struct snd_soc_component_driver soc_codec_dev_rt715 = { + .set_bias_level = rt715_set_bias_level, + .controls = rt715_snd_controls, + .num_controls = array_size(rt715_snd_controls), + .dapm_widgets = rt715_dapm_widgets, + .num_dapm_widgets = array_size(rt715_dapm_widgets), + .dapm_routes = rt715_audio_map, + .num_dapm_routes = array_size(rt715_audio_map), +}; + +static int rt715_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), gfp_kernel); + if (!stream) + return -enomem; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == sndrv_pcm_stream_playback) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt715_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) + +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, null); + kfree(stream); +} + +static int rt715_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + unsigned int val = 0; + + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -einval; + + if (!rt715->slave) + return -einval; + + switch (dai->id) { + case rt715_aif1: + direction = sdw_data_dir_tx; + port = 6; + rt715_index_write(rt715->regmap, rt715_sdw_input_sel, 0xa500); + break; + case rt715_aif2: + direction = sdw_data_dir_tx; + port = 4; + rt715_index_write(rt715->regmap, rt715_sdw_input_sel, 0xa000); + break; + default: + dev_err(component->dev, "invalid dai id %d ", dai->id); + return -einval; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt715->slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "unable to configure port "); + return retval; + } + + switch (params_rate(params)) { + /* bit 14 0:48k 1:44.1k */ + /* bit 15 stream type 0:pcm 1:non-pcm, should always be pcm */ + case 44100: + val |= 0x40 << 8; + break; + case 48000: + val |= 0x0 << 8; + break; + default: + dev_err(component->dev, "unsupported sample rate %d ", + params_rate(params)); + return -einval; + } + + if (params_channels(params) <= 16) { + /* bit 3:0 number of channel */ + val |= (params_channels(params) - 1); + } else { + dev_err(component->dev, "unsupported channels %d ", + params_channels(params)); + return -einval; + } + + switch (params_width(params)) { + /* bit 6:4 bits per sample */ + case 8: + break; + case 16: + val |= (0x1 << 4); + break; + case 20: + val |= (0x2 << 4); + break; + case 24: + val |= (0x3 << 4); + break; + case 32: + val |= (0x4 << 4); + break; + default: + return -einval; + } + + regmap_write(rt715->regmap, rt715_mic_adc_format_h, val); + regmap_write(rt715->regmap, rt715_mic_line_format_h, val); + regmap_write(rt715->regmap, rt715_mix_adc_format_h, val); + regmap_write(rt715->regmap, rt715_mix_adc2_format_h, val); + + return retval; +} + +static int rt715_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt715->slave) + return -einval; + + sdw_stream_remove_slave(rt715->slave, stream->sdw_stream); + return 0; +} + +#define rt715_stereo_rates (sndrv_pcm_rate_44100 | sndrv_pcm_rate_48000) +#define rt715_formats (sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s20_3le | \ + sndrv_pcm_fmtbit_s24_le | sndrv_pcm_fmtbit_s8) + +static struct snd_soc_dai_ops rt715_ops = { + .hw_params = rt715_pcm_hw_params, + .hw_free = rt715_pcm_hw_free, + .set_sdw_stream = rt715_set_sdw_stream, + .shutdown = rt715_shutdown, +}; + +static struct snd_soc_dai_driver rt715_dai[] = { + { + .name = "rt715-aif1", + .id = rt715_aif1, + .capture = { + .stream_name = "dp6 capture", + .channels_min = 1, + .channels_max = 2, + .rates = rt715_stereo_rates, + .formats = rt715_formats, + }, + .ops = &rt715_ops, + }, + { + .name = "rt715-aif2", + .id = rt715_aif2, + .capture = { + .stream_name = "dp4 capture", + .channels_min = 1, + .channels_max = 2, + .rates = rt715_stereo_rates, + .formats = rt715_formats, + }, + .ops = &rt715_ops, + }, +}; + +/* bus clock frequency */ +#define rt715_clk_freq_9600000hz 9600000 +#define rt715_clk_freq_12000000hz 12000000 +#define rt715_clk_freq_6000000hz 6000000 +#define rt715_clk_freq_4800000hz 4800000 +#define rt715_clk_freq_2400000hz 2400000 +#define rt715_clk_freq_12288000hz 12288000 + +int rt715_clock_config(struct device *dev) +{ + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt715->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case rt715_clk_freq_12000000hz: + value = 0x0; + break; + case rt715_clk_freq_6000000hz: + value = 0x1; + break; + case rt715_clk_freq_9600000hz: + value = 0x2; + break; + case rt715_clk_freq_4800000hz: + value = 0x3; + break; + case rt715_clk_freq_2400000hz: + value = 0x4; + break; + case rt715_clk_freq_12288000hz: + value = 0x5; + break; + default: + return -einval; + } + + regmap_write(rt715->regmap, 0xe0, value); + regmap_write(rt715->regmap, 0xf0, value); + + return 0; +} + +int rt715_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave) +{ + struct rt715_priv *rt715; + int ret; + + rt715 = devm_kzalloc(dev, sizeof(*rt715), gfp_kernel); + if (!rt715) + return -enomem; + + dev_set_drvdata(dev, rt715); + rt715->slave = slave; + rt715->regmap = regmap; + rt715->sdw_regmap = sdw_regmap; + + /* + * mark hw_init to false + * hw init will be performed when device reports present + */ + rt715->hw_init = false; + rt715->first_hw_init = false; + + ret = devm_snd_soc_register_component(dev, + &soc_codec_dev_rt715, + rt715_dai, + array_size(rt715_dai)); + + return ret; +} + +int rt715_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt715_priv *rt715 = dev_get_drvdata(dev); + + if (rt715->hw_init) + return 0; + + /* + * pm runtime is only enabled when a slave reports as attached + */ + if (!rt715->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + /* mute nid=08h/09h */ + regmap_write(rt715->regmap, rt715_set_gain_line_adc_h, 0xb080); + regmap_write(rt715->regmap, rt715_set_gain_mix_adc_h, 0xb080); + /* mute nid=07h/27h */ + regmap_write(rt715->regmap, rt715_set_gain_mic_adc_h, 0xb080); + regmap_write(rt715->regmap, rt715_set_gain_mix_adc2_h, 0xb080); + + /* set pin widget */ + regmap_write(rt715->regmap, rt715_set_pin_dmic1, 0x20); + regmap_write(rt715->regmap, rt715_set_pin_dmic2, 0x20); + regmap_write(rt715->regmap, rt715_set_pin_dmic3, 0x20); + regmap_write(rt715->regmap, rt715_set_pin_dmic4, 0x20); + /* set converter stream */ + regmap_write(rt715->regmap, rt715_set_streamid_line_adc, 0x10); + regmap_write(rt715->regmap, rt715_set_streamid_mix_adc, 0x10); + regmap_write(rt715->regmap, rt715_set_streamid_mic_adc, 0x10); + regmap_write(rt715->regmap, rt715_set_streamid_mix_adc2, 0x10); + /* set configuration default */ + regmap_write(rt715->regmap, rt715_set_dmic1_config_default1, 0xd0); + regmap_write(rt715->regmap, rt715_set_dmic1_config_default2, 0x11); + regmap_write(rt715->regmap, rt715_set_dmic1_config_default3, 0xa1); + regmap_write(rt715->regmap, rt715_set_dmic1_config_default4, 0x81); + regmap_write(rt715->regmap, rt715_set_dmic2_config_default1, 0xd1); + regmap_write(rt715->regmap, rt715_set_dmic2_config_default2, 0x11); + regmap_write(rt715->regmap, rt715_set_dmic2_config_default3, 0xa1); + regmap_write(rt715->regmap, rt715_set_dmic2_config_default4, 0x81); + regmap_write(rt715->regmap, rt715_set_dmic3_config_default1, 0xd0); + regmap_write(rt715->regmap, rt715_set_dmic3_config_default2, 0x11); + regmap_write(rt715->regmap, rt715_set_dmic3_config_default3, 0xa1); + regmap_write(rt715->regmap, rt715_set_dmic3_config_default4, 0x81); + regmap_write(rt715->regmap, rt715_set_dmic4_config_default1, 0xd1); + regmap_write(rt715->regmap, rt715_set_dmic4_config_default2, 0x11); + regmap_write(rt715->regmap, rt715_set_dmic4_config_default3, 0xa1); + regmap_write(rt715->regmap, rt715_set_dmic4_config_default4, 0x81); + + /* finish initial settings, set power to d3 */ + regmap_write(rt715->regmap, rt715_set_audio_power_state, ac_pwrst_d3); + + if (rt715->first_hw_init) + regcache_mark_dirty(rt715->regmap); + else + rt715->first_hw_init = true; + + /* mark slave initialization complete */ + rt715->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + return 0; +} + +module_description("asoc rt715 driver"); +module_description("asoc rt715 driver sdw"); +module_author("jack yu <jack.yu@realtek.com>"); +module_license("gpl v2"); diff --git a/sound/soc/codecs/rt715.h b/sound/soc/codecs/rt715.h --- /dev/null +++ b/sound/soc/codecs/rt715.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * rt715.h -- rt715 alsa soc audio driver header + * + * copyright(c) 2019 realtek semiconductor corp. + */ + +#ifndef __rt715_h__ +#define __rt715_h__ + +#include <linux/regulator/consumer.h> + +struct rt715_priv { + struct regmap *regmap; + struct regmap *sdw_regmap; + struct snd_soc_codec *codec; + struct sdw_slave *slave; + int dbg_nid; + int dbg_vid; + int dbg_payload; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +/* nid */ +#define rt715_audio_function_group 0x01 +#define rt715_mic_adc 0x07 +#define rt715_line_adc 0x08 +#define rt715_mix_adc 0x09 +#define rt715_dmic1 0x12 +#define rt715_dmic2 0x13 +#define rt715_mic1 0x18 +#define rt715_mic2 0x19 +#define rt715_line1 0x1a +#define rt715_line2 0x1b +#define rt715_dmic3 0x1d +#define rt715_dmic4 0x29 +#define rt715_vendor_registers 0x20 +#define rt715_mux_in1 0x22 +#define rt715_mux_in2 0x23 +#define rt715_mux_in3 0x24 +#define rt715_mux_in4 0x25 +#define rt715_mix_adc2 0x27 +#define rt715_inline_cmd 0x55 + +/* index (nid:20h) */ +#define rt715_sdw_input_sel 0x39 +#define rt715_ext_dmic_clk_ctrl2 0x54 + +/* verb */ +#define rt715_verb_set_connect_sel 0x3100 +#define rt715_verb_get_connect_sel 0xb100 +#define rt715_verb_set_eapd_btlenable 0x3c00 +#define rt715_verb_set_power_state 0x3500 +#define rt715_verb_set_channel_streamid 0x3600 +#define rt715_verb_set_pin_widget_control 0x3700 +#define rt715_verb_set_config_default1 0x4c00 +#define rt715_verb_set_config_default2 0x4d00 +#define rt715_verb_set_config_default3 0x4e00 +#define rt715_verb_set_config_default4 0x4f00 +#define rt715_verb_set_unsolicited_enable 0x3800 +#define rt715_set_amp_gain_mute_h 0x7300 +#define rt715_set_amp_gain_mute_l 0x8380 +#define rt715_read_hda_3 0x2012 +#define rt715_read_hda_2 0x2013 +#define rt715_read_hda_1 0x2014 +#define rt715_read_hda_0 0x2015 +#define rt715_priv_index_w_h 0x7520 +#define rt715_priv_index_w_l 0x85a0 +#define rt715_priv_data_w_h 0x7420 +#define rt715_priv_data_w_l 0x84a0 +#define rt715_priv_index_r_h 0x9d20 +#define rt715_priv_index_r_l 0xada0 +#define rt715_priv_data_r_h 0x9c20 +#define rt715_priv_data_r_l 0xaca0 +#define rt715_mic_adc_format_h 0x7207 +#define rt715_mic_adc_format_l 0x8287 +#define rt715_mic_line_format_h 0x7208 +#define rt715_mic_line_format_l 0x8288 +#define rt715_mix_adc_format_h 0x7209 +#define rt715_mix_adc_format_l 0x8289 +#define rt715_mix_adc2_format_h 0x7227 +#define rt715_mix_adc2_format_l 0x82a7 +#define rt715_func_reset 0xff01 + +#define rt715_set_audio_power_state\ + (rt715_verb_set_power_state | rt715_audio_function_group) +#define rt715_set_pin_dmic1\ + (rt715_verb_set_pin_widget_control | rt715_dmic1) +#define rt715_set_pin_dmic2\ + (rt715_verb_set_pin_widget_control | rt715_dmic2) +#define rt715_set_pin_dmic3\ + (rt715_verb_set_pin_widget_control | rt715_dmic3) +#define rt715_set_pin_dmic4\ + (rt715_verb_set_pin_widget_control | rt715_dmic4) +#define rt715_set_pin_mic1\ + (rt715_verb_set_pin_widget_control | rt715_mic1) +#define rt715_set_pin_mic2\ + (rt715_verb_set_pin_widget_control | rt715_mic2) +#define rt715_set_pin_line1\ + (rt715_verb_set_pin_widget_control | rt715_line1) +#define rt715_set_pin_line2\ + (rt715_verb_set_pin_widget_control | rt715_line2) +#define rt715_set_mic1_unsolicited_enable\ + (rt715_verb_set_unsolicited_enable | rt715_mic1) +#define rt715_set_mic2_unsolicited_enable\ + (rt715_verb_set_unsolicited_enable | rt715_mic2) +#define rt715_set_streamid_mic_adc\ + (rt715_verb_set_channel_streamid | rt715_mic_adc) +#define rt715_set_streamid_line_adc\ + (rt715_verb_set_channel_streamid | rt715_line_adc) +#define rt715_set_streamid_mix_adc\ + (rt715_verb_set_channel_streamid | rt715_mix_adc) +#define rt715_set_streamid_mix_adc2\ + (rt715_verb_set_channel_streamid | rt715_mix_adc2) +#define rt715_set_gain_mic_adc_l\ + (rt715_set_amp_gain_mute_l | rt715_mic_adc) +#define rt715_set_gain_mic_adc_h\ + (rt715_set_amp_gain_mute_h | rt715_mic_adc) +#define rt715_set_gain_line_adc_l\ + (rt715_set_amp_gain_mute_l | rt715_line_adc) +#define rt715_set_gain_line_adc_h\ + (rt715_set_amp_gain_mute_h | rt715_line_adc) +#define rt715_set_gain_mix_adc_l\ + (rt715_set_amp_gain_mute_l | rt715_mix_adc) +#define rt715_set_gain_mix_adc_h\ + (rt715_set_amp_gain_mute_h | rt715_mix_adc) +#define rt715_set_gain_mix_adc2_l\ + (rt715_set_amp_gain_mute_l | rt715_mix_adc2) +#define rt715_set_gain_mix_adc2_h\ + (rt715_set_amp_gain_mute_h | rt715_mix_adc2) +#define rt715_set_gain_dmic1_l\ + (rt715_set_amp_gain_mute_l | rt715_dmic1) +#define rt715_set_gain_dmic1_h\ + (rt715_set_amp_gain_mute_h | rt715_dmic1) +#define rt715_set_gain_dmic2_l\ + (rt715_set_amp_gain_mute_l | rt715_dmic2) +#define rt715_set_gain_dmic2_h\ + (rt715_set_amp_gain_mute_h | rt715_dmic2) +#define rt715_set_gain_dmic3_l\ + (rt715_set_amp_gain_mute_l | rt715_dmic3) +#define rt715_set_gain_dmic3_h\ + (rt715_set_amp_gain_mute_h | rt715_dmic3) +#define rt715_set_gain_dmic4_l\ + (rt715_set_amp_gain_mute_l | rt715_dmic4) +#define rt715_set_gain_dmic4_h\ + (rt715_set_amp_gain_mute_h | rt715_dmic4) +#define rt715_set_gain_mic1_l\ + (rt715_set_amp_gain_mute_l | rt715_mic1) +#define rt715_set_gain_mic1_h\ + (rt715_set_amp_gain_mute_h | rt715_mic1) +#define rt715_set_gain_mic2_l\ + (rt715_set_amp_gain_mute_l | rt715_mic2) +#define rt715_set_gain_mic2_h\ + (rt715_set_amp_gain_mute_h | rt715_mic2) +#define rt715_set_gain_line1_l\ + (rt715_set_amp_gain_mute_l | rt715_line1) +#define rt715_set_gain_line1_h\ + (rt715_set_amp_gain_mute_h | rt715_line1) +#define rt715_set_gain_line2_l\ + (rt715_set_amp_gain_mute_l | rt715_line2) +#define rt715_set_gain_line2_h\ + (rt715_set_amp_gain_mute_h | rt715_line2) +#define rt715_set_dmic1_config_default1\ + (rt715_verb_set_config_default1 | rt715_dmic1) +#define rt715_set_dmic2_config_default1\ + (rt715_verb_set_config_default1 | rt715_dmic2) +#define rt715_set_dmic1_config_default2\ + (rt715_verb_set_config_default2 | rt715_dmic1) +#define rt715_set_dmic2_config_default2\ + (rt715_verb_set_config_default2 | rt715_dmic2) +#define rt715_set_dmic1_config_default3\ + (rt715_verb_set_config_default3 | rt715_dmic1) +#define rt715_set_dmic2_config_default3\ + (rt715_verb_set_config_default3 | rt715_dmic2) +#define rt715_set_dmic1_config_default4\ + (rt715_verb_set_config_default4 | rt715_dmic1) +#define rt715_set_dmic2_config_default4\ + (rt715_verb_set_config_default4 | rt715_dmic2) +#define rt715_set_dmic3_config_default1\ + (rt715_verb_set_config_default1 | rt715_dmic3) +#define rt715_set_dmic4_config_default1\ + (rt715_verb_set_config_default1 | rt715_dmic4) +#define rt715_set_dmic3_config_default2\ + (rt715_verb_set_config_default2 | rt715_dmic3) +#define rt715_set_dmic4_config_default2\ + (rt715_verb_set_config_default2 | rt715_dmic4) +#define rt715_set_dmic3_config_default3\ + (rt715_verb_set_config_default3 | rt715_dmic3) +#define rt715_set_dmic4_config_default3\ + (rt715_verb_set_config_default3 | rt715_dmic4) +#define rt715_set_dmic3_config_default4\ + (rt715_verb_set_config_default4 | rt715_dmic3) +#define rt715_set_dmic4_config_default4\ + (rt715_verb_set_config_default4 | rt715_dmic4) + +#define rt715_mute_sft 7 +#define rt715_dir_in_sft 6 +#define rt715_dir_out_sft 7 + +enum { + rt715_aif1, + rt715_aif2, + rt715_aifs, +}; + +int rt715_io_init(struct device *dev, struct sdw_slave *slave); +int rt715_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave); + +int hda_to_sdw(unsigned int nid, unsigned int verb, unsigned int payload, + unsigned int *sdw_addr_h, unsigned int *sdw_data_h, + unsigned int *sdw_addr_l, unsigned int *sdw_data_l); +int rt715_clock_config(struct device *dev); +#endif /* __rt715_h__ */
Audio
d1ede0641b05e43542a6af330f6ca41014a02a5f
jack yu
sound
soc
codecs