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
asoc: codecs: lpass-rx-macro: add iir widgets
this patch adds iir widgets and mixers on this codec
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
adds support for two codec macro blocks(tx and rx) available in qualcomm lpass (low power audio subsystem)
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'codecs']
['c']
1
264
0
--- diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c +/* codec supports 2 iir filters */ +enum { + iir0 = 0, + iir1, + iir_max, +}; + +/* each iir has 5 filter stages */ +enum { + band1 = 0, + band2, + band3, + band4, + band5, + band_max, +}; + +#define rx_macro_iir_filter_size (sizeof(u32) * band_max) + +#define rx_macro_iir_filter_ctl(xname, iidx, bidx) \ +{ \ + .iface = sndrv_ctl_elem_iface_mixer, .name = xname, \ + .info = rx_macro_iir_filter_info, \ + .get = rx_macro_get_iir_band_audio_mixer, \ + .put = rx_macro_put_iir_band_audio_mixer, \ + .private_value = (unsigned long)&(struct wcd_iir_filter_ctl) { \ + .iir_idx = iidx, \ + .band_idx = bidx, \ + .bytes_ext = {.max = rx_macro_iir_filter_size, }, \ + } \ +} + +struct wcd_iir_filter_ctl { + unsigned int iir_idx; + unsigned int band_idx; + struct soc_bytes_ext bytes_ext; +}; + +static int rx_macro_set_iir_gain(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: /* fall through */ + case snd_soc_dapm_pre_pmd: + if (strnstr(w->name, "iir0", sizeof("iir0"))) { + snd_soc_component_write(component, + cdc_rx_sidetone_iir0_iir_gain_b1_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir0_iir_gain_b1_ctl)); + snd_soc_component_write(component, + cdc_rx_sidetone_iir0_iir_gain_b2_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir0_iir_gain_b2_ctl)); + snd_soc_component_write(component, + cdc_rx_sidetone_iir0_iir_gain_b3_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir0_iir_gain_b3_ctl)); + snd_soc_component_write(component, + cdc_rx_sidetone_iir0_iir_gain_b4_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir0_iir_gain_b4_ctl)); + } else { + snd_soc_component_write(component, + cdc_rx_sidetone_iir1_iir_gain_b1_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir1_iir_gain_b1_ctl)); + snd_soc_component_write(component, + cdc_rx_sidetone_iir1_iir_gain_b2_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir1_iir_gain_b2_ctl)); + snd_soc_component_write(component, + cdc_rx_sidetone_iir1_iir_gain_b3_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir1_iir_gain_b3_ctl)); + snd_soc_component_write(component, + cdc_rx_sidetone_iir1_iir_gain_b4_ctl, + snd_soc_component_read(component, + cdc_rx_sidetone_iir1_iir_gain_b4_ctl)); + } + break; + } + return 0; +} + +static uint32_t get_iir_band_coeff(struct snd_soc_component *component, + int iir_idx, int band_idx, int coeff_idx) +{ + u32 value; + int reg, b2_reg; + + /* address does not automatically update if reading */ + reg = cdc_rx_sidetone_iir0_iir_coef_b1_ctl + 16 * iir_idx; + b2_reg = cdc_rx_sidetone_iir0_iir_coef_b2_ctl + 16 * iir_idx; + + snd_soc_component_write(component, reg, + ((band_idx * band_max + coeff_idx) * + sizeof(uint32_t)) & 0x7f); + + value = snd_soc_component_read(component, b2_reg); + snd_soc_component_write(component, reg, + ((band_idx * band_max + coeff_idx) + * sizeof(uint32_t) + 1) & 0x7f); + + value |= (snd_soc_component_read(component, b2_reg) << 8); + snd_soc_component_write(component, reg, + ((band_idx * band_max + coeff_idx) + * sizeof(uint32_t) + 2) & 0x7f); + + value |= (snd_soc_component_read(component, b2_reg) << 16); + snd_soc_component_write(component, reg, + ((band_idx * band_max + coeff_idx) + * sizeof(uint32_t) + 3) & 0x7f); + + /* mask bits top 2 bits since they are reserved */ + value |= (snd_soc_component_read(component, b2_reg) << 24); + return value; +} + +static void set_iir_band_coeff(struct snd_soc_component *component, + int iir_idx, int band_idx, uint32_t value) +{ + int reg = cdc_rx_sidetone_iir0_iir_coef_b2_ctl + 16 * iir_idx; + + snd_soc_component_write(component, reg, (value & 0xff)); + snd_soc_component_write(component, reg, (value >> 8) & 0xff); + snd_soc_component_write(component, reg, (value >> 16) & 0xff); + /* mask top 2 bits, 7-8 are reserved */ + snd_soc_component_write(component, reg, (value >> 24) & 0x3f); +} + +static int rx_macro_put_iir_band_audio_mixer( + struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd_iir_filter_ctl *ctl = + (struct wcd_iir_filter_ctl *)kcontrol->private_value; + struct soc_bytes_ext *params = &ctl->bytes_ext; + int iir_idx = ctl->iir_idx; + int band_idx = ctl->band_idx; + u32 coeff[band_max]; + int reg = cdc_rx_sidetone_iir0_iir_coef_b1_ctl + 16 * iir_idx; + + memcpy(&coeff[0], ucontrol->value.bytes.data, params->max); + + /* mask top bit it is reserved */ + /* updates addr automatically for each b2 write */ + snd_soc_component_write(component, reg, (band_idx * band_max * + sizeof(uint32_t)) & 0x7f); + + set_iir_band_coeff(component, iir_idx, band_idx, coeff[0]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[1]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[2]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[3]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[4]); + + return 0; +} + +static int rx_macro_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd_iir_filter_ctl *ctl = + (struct wcd_iir_filter_ctl *)kcontrol->private_value; + struct soc_bytes_ext *params = &ctl->bytes_ext; + int iir_idx = ctl->iir_idx; + int band_idx = ctl->band_idx; + u32 coeff[band_max]; + + coeff[0] = get_iir_band_coeff(component, iir_idx, band_idx, 0); + coeff[1] = get_iir_band_coeff(component, iir_idx, band_idx, 1); + coeff[2] = get_iir_band_coeff(component, iir_idx, band_idx, 2); + coeff[3] = get_iir_band_coeff(component, iir_idx, band_idx, 3); + coeff[4] = get_iir_band_coeff(component, iir_idx, band_idx, 4); + + memcpy(ucontrol->value.bytes.data, &coeff[0], params->max); + + return 0; +} + +static int rx_macro_iir_filter_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *ucontrol) +{ + struct wcd_iir_filter_ctl *ctl = + (struct wcd_iir_filter_ctl *)kcontrol->private_value; + struct soc_bytes_ext *params = &ctl->bytes_ext; + + ucontrol->type = sndrv_ctl_elem_type_bytes; + ucontrol->count = params->max; + + return 0; +} + -84, 40, digital_gain), + + soc_single_s8_tlv("iir0 inp0 volume", + cdc_rx_sidetone_iir0_iir_gain_b1_ctl, -84, 40, + digital_gain), + soc_single_s8_tlv("iir0 inp1 volume", + cdc_rx_sidetone_iir0_iir_gain_b2_ctl, -84, 40, + digital_gain), + soc_single_s8_tlv("iir0 inp2 volume", + cdc_rx_sidetone_iir0_iir_gain_b3_ctl, -84, 40, + digital_gain), + soc_single_s8_tlv("iir0 inp3 volume", + cdc_rx_sidetone_iir0_iir_gain_b4_ctl, -84, 40, + digital_gain), + soc_single_s8_tlv("iir1 inp0 volume", + cdc_rx_sidetone_iir1_iir_gain_b1_ctl, -84, 40, + digital_gain), + soc_single_s8_tlv("iir1 inp1 volume", + cdc_rx_sidetone_iir1_iir_gain_b2_ctl, -84, 40, + digital_gain), + soc_single_s8_tlv("iir1 inp2 volume", + cdc_rx_sidetone_iir1_iir_gain_b3_ctl, -84, 40, + digital_gain), + soc_single_s8_tlv("iir1 inp3 volume", + cdc_rx_sidetone_iir1_iir_gain_b4_ctl, -84, 40, + digital_gain), + + soc_single("iir1 band1 switch", cdc_rx_sidetone_iir0_iir_ctl, + 0, 1, 0), + soc_single("iir1 band2 switch", cdc_rx_sidetone_iir0_iir_ctl, + 1, 1, 0), + soc_single("iir1 band3 switch", cdc_rx_sidetone_iir0_iir_ctl, + 2, 1, 0), + soc_single("iir1 band4 switch", cdc_rx_sidetone_iir0_iir_ctl, + 3, 1, 0), + soc_single("iir1 band5 switch", cdc_rx_sidetone_iir0_iir_ctl, + 4, 1, 0), + soc_single("iir2 band1 switch", cdc_rx_sidetone_iir1_iir_ctl, + 0, 1, 0), + soc_single("iir2 band2 switch", cdc_rx_sidetone_iir1_iir_ctl, + 1, 1, 0), + soc_single("iir2 band3 switch", cdc_rx_sidetone_iir1_iir_ctl, + 2, 1, 0), + soc_single("iir2 band4 switch", cdc_rx_sidetone_iir1_iir_ctl, + 3, 1, 0), + soc_single("iir2 band5 switch", cdc_rx_sidetone_iir1_iir_ctl, + 4, 1, 0), + + rx_macro_iir_filter_ctl("iir0 band1", iir0, band1), + rx_macro_iir_filter_ctl("iir0 band2", iir0, band2), + rx_macro_iir_filter_ctl("iir0 band3", iir0, band3), + rx_macro_iir_filter_ctl("iir0 band4", iir0, band4), + rx_macro_iir_filter_ctl("iir0 band5", iir0, band5), + + rx_macro_iir_filter_ctl("iir1 band1", iir1, band1), + rx_macro_iir_filter_ctl("iir1 band2", iir1, band2), + rx_macro_iir_filter_ctl("iir1 band3", iir1, band3), + rx_macro_iir_filter_ctl("iir1 band4", iir1, band4), + rx_macro_iir_filter_ctl("iir1 band5", iir1, band5), + + + snd_soc_dapm_mixer_e("iir0", cdc_rx_sidetone_iir0_iir_path_ctl, + 4, 0, null, 0, rx_macro_set_iir_gain, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd), + snd_soc_dapm_mixer_e("iir1", cdc_rx_sidetone_iir1_iir_path_ctl, + 4, 0, null, 0, rx_macro_set_iir_gain, + snd_soc_dapm_post_pmu | snd_soc_dapm_pre_pmd),
Audio
f3ce6f3c9a994d3fa5057cadfaa1d883e0d938fa
srinivas kandagatla
sound
soc
codecs
asoc: qcom: dt-bindings: add bindings for lpass tx macro codec
this binding is for lpass has internal codec tx macro which is for connecting with soundwire tx codecs like wcd938x.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
adds support for two codec macro blocks(tx and rx) available in qualcomm lpass (low power audio subsystem)
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'codecs']
['yaml']
1
67
0
--- diff --git a/documentation/devicetree/bindings/sound/qcom,lpass-tx-macro.yaml b/documentation/devicetree/bindings/sound/qcom,lpass-tx-macro.yaml --- /dev/null +++ b/documentation/devicetree/bindings/sound/qcom,lpass-tx-macro.yaml +# spdx-license-identifier: (gpl-2.0-only or bsd-2-clause) +%yaml 1.2 +--- +$id: http://devicetree.org/schemas/sound/qcom,lpass-tx-macro.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: lpass(low power audio subsystem) tx macro audio codec dt bindings + +maintainers: + - srinivas kandagatla <srinivas.kandagatla@linaro.org> + +properties: + compatible: + const: qcom,sm8250-lpass-tx-macro + + reg: + maxitems: 1 + + "#sound-dai-cells": + const: 1 + + '#clock-cells': + const: 0 + + clocks: + maxitems: 5 + + clock-names: + items: + - const: mclk + - const: npl + - const: macro + - const: dcodec + - const: fsgen + + clock-output-names: + items: + - const: mclk + + qcom,dmic-sample-rate: + description: dmic sample rate + $ref: /schemas/types.yaml#/definitions/uint32 + +required: + - compatible + - reg + - "#sound-dai-cells" + +additionalproperties: false + +examples: + - | + #include <dt-bindings/sound/qcom,q6afe.h> + codec@3220000 { + compatible = "qcom,sm8250-lpass-tx-macro"; + reg = <0x3220000 0x1000>; + #sound-dai-cells = <1>; + #clock-cells = <0>; + clocks = <&aoncc 0>, + <&aoncc 1>, + <&q6afecc lpass_hw_macro_vote lpass_clk_attribute_couple_no>, + <&q6afecc lpass_hw_dcodec_vote lpass_clk_attribute_couple_no>, + <&vamacro>; + clock-names = "mclk", "npl", "macro", "dcodec", "fsgen"; + clock-output-names = "mclk"; + qcom,dmic-sample-rate = <600000>; + };
Audio
ca955cc980afc066a380567e371480634e48eb7e
srinivas kandagatla rob herring robh kernel org
documentation
devicetree
bindings, sound
asoc: codecs: lpass-tx-macro: add dapm widgets and route
this patch adds dapm widgets and routes on this codec
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
adds support for two codec macro blocks(tx and rx) available in qualcomm lpass (low power audio subsystem)
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'codecs']
['c']
1
685
0
--- diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c +static int tx_macro_mclk_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 tx_macro *tx = snd_soc_component_get_drvdata(component); + + switch (event) { + case snd_soc_dapm_pre_pmu: + tx_macro_mclk_enable(tx, true); + break; + case snd_soc_dapm_post_pmd: + tx_macro_mclk_enable(tx, false); + break; + default: + break; + } + + return 0; +} + +static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int val, dmic; + u16 mic_sel_reg; + u16 dmic_clk_reg; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + val = ucontrol->value.enumerated.item[0]; + + switch (e->reg) { + case cdc_tx_inp_mux_adc_mux0_cfg0: + mic_sel_reg = cdc_tx0_tx_path_cfg0; + break; + case cdc_tx_inp_mux_adc_mux1_cfg0: + mic_sel_reg = cdc_tx1_tx_path_cfg0; + break; + case cdc_tx_inp_mux_adc_mux2_cfg0: + mic_sel_reg = cdc_tx2_tx_path_cfg0; + break; + case cdc_tx_inp_mux_adc_mux3_cfg0: + mic_sel_reg = cdc_tx3_tx_path_cfg0; + break; + case cdc_tx_inp_mux_adc_mux4_cfg0: + mic_sel_reg = cdc_tx4_tx_path_cfg0; + break; + case cdc_tx_inp_mux_adc_mux5_cfg0: + mic_sel_reg = cdc_tx5_tx_path_cfg0; + break; + case cdc_tx_inp_mux_adc_mux6_cfg0: + mic_sel_reg = cdc_tx6_tx_path_cfg0; + break; + case cdc_tx_inp_mux_adc_mux7_cfg0: + mic_sel_reg = cdc_tx7_tx_path_cfg0; + break; + } + + if (val != 0) { + if (val < 5) { + snd_soc_component_write_field(component, mic_sel_reg, + cdc_txn_adc_dmic_sel_mask, 0); + } else { + snd_soc_component_write_field(component, mic_sel_reg, + cdc_txn_adc_dmic_sel_mask, 1); + dmic = tx_adc_to_dmic(val); + dmic_clk_reg = cdc_tx_top_csr_swr_dmicn_ctl(dmic); + snd_soc_component_write_field(component, dmic_clk_reg, + cdc_tx_swr_dmic_clk_sel_mask, + tx->dmic_clk_div); + } + } + + return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); +} + +static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); + struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; + u32 dai_id = widget->shift; + u32 dec_id = mc->shift; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + if (test_bit(dec_id, &tx->active_ch_mask[dai_id])) + ucontrol->value.integer.value[0] = 1; + else + ucontrol->value.integer.value[0] = 0; + + return 0; +} + +static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); + struct snd_soc_dapm_update *update = null; + struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; + u32 dai_id = widget->shift; + u32 dec_id = mc->shift; + u32 enable = ucontrol->value.integer.value[0]; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + if (enable) { + set_bit(dec_id, &tx->active_ch_mask[dai_id]); + tx->active_ch_cnt[dai_id]++; + tx->active_decimator[dai_id] = dec_id; + } else { + tx->active_ch_cnt[dai_id]--; + clear_bit(dec_id, &tx->active_ch_mask[dai_id]); + tx->active_decimator[dai_id] = -1; + } + snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update); + + return 0; +} + +static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + unsigned int decimator; + u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg, tx_gain_ctl_reg; + u8 hpf_cut_off_freq; + int hpf_delay = tx_macro_dmic_hpf_delay_ms; + int unmute_delay = tx_macro_dmic_unmute_delay_ms; + u16 adc_mux_reg, adc_reg, adc_n, dmic; + u16 dmic_clk_reg; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + decimator = w->shift; + tx_vol_ctl_reg = cdc_txn_tx_path_ctl(decimator); + hpf_gate_reg = cdc_txn_tx_path_sec2(decimator); + dec_cfg_reg = cdc_txn_tx_path_cfg0(decimator); + tx_gain_ctl_reg = cdc_txn_tx_vol_ctl(decimator); + + switch (event) { + case snd_soc_dapm_pre_pmu: + adc_mux_reg = cdc_tx_inp_mux_adc_muxn_cfg1(decimator); + if (snd_soc_component_read(component, adc_mux_reg) & swr_mic) { + adc_reg = cdc_tx_inp_mux_adc_muxn_cfg0(decimator); + adc_n = snd_soc_component_read(component, adc_reg) & + cdc_tx_macro_swr_mic_mux_sel_mask; + if (adc_n >= tx_adc_max) { + dmic = tx_adc_to_dmic(adc_n); + dmic_clk_reg = cdc_tx_top_csr_swr_dmicn_ctl(dmic); + + snd_soc_component_write_field(component, dmic_clk_reg, + cdc_tx_swr_dmic_clk_sel_mask, + tx->dmic_clk_div); + } + } + snd_soc_component_write_field(component, dec_cfg_reg, + cdc_txn_adc_mode_mask, + tx->dec_mode[decimator]); + /* enable tx pga mute */ + snd_soc_component_write_field(component, tx_vol_ctl_reg, + cdc_txn_pga_mute_mask, 0x1); + break; + case snd_soc_dapm_post_pmu: + snd_soc_component_write_field(component, tx_vol_ctl_reg, + cdc_txn_clk_en_mask, 0x1); + if (!is_amic_enabled(component, decimator)) { + snd_soc_component_update_bits(component, hpf_gate_reg, 0x01, 0x00); + /* minimum 1 clk cycle delay is required as per hw spec */ + usleep_range(1000, 1010); + } + hpf_cut_off_freq = snd_soc_component_read_field(component, dec_cfg_reg, + cdc_txn_hpf_cut_freq_mask); + + tx->tx_hpf_work[decimator].hpf_cut_off_freq = + hpf_cut_off_freq; + + if (hpf_cut_off_freq != cf_min_3db_150hz) + snd_soc_component_write_field(component, dec_cfg_reg, + cdc_txn_hpf_cut_freq_mask, + cf_min_3db_150hz); + + if (is_amic_enabled(component, decimator)) { + hpf_delay = tx_macro_amic_hpf_delay_ms; + unmute_delay = tx_macro_amic_unmute_delay_ms; + } + /* schedule work queue to remove mute */ + queue_delayed_work(system_freezable_wq, + &tx->tx_mute_dwork[decimator].dwork, + msecs_to_jiffies(unmute_delay)); + if (tx->tx_hpf_work[decimator].hpf_cut_off_freq != cf_min_3db_150hz) { + queue_delayed_work(system_freezable_wq, + &tx->tx_hpf_work[decimator].dwork, + msecs_to_jiffies(hpf_delay)); + snd_soc_component_update_bits(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x02); + if (!is_amic_enabled(component, decimator)) + snd_soc_component_update_bits(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x00); + snd_soc_component_update_bits(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x01); + + /* + * 6ms delay is required as per hw spec + */ + usleep_range(6000, 6010); + } + /* apply gain after decimator is enabled */ + snd_soc_component_write(component, tx_gain_ctl_reg, + snd_soc_component_read(component, + tx_gain_ctl_reg)); + if (tx->bcs_enable) { + snd_soc_component_update_bits(component, dec_cfg_reg, + 0x01, 0x01); + tx->bcs_clk_en = true; + } + break; + case snd_soc_dapm_pre_pmd: + hpf_cut_off_freq = + tx->tx_hpf_work[decimator].hpf_cut_off_freq; + snd_soc_component_write_field(component, tx_vol_ctl_reg, + cdc_txn_pga_mute_mask, 0x1); + if (cancel_delayed_work_sync( + &tx->tx_hpf_work[decimator].dwork)) { + if (hpf_cut_off_freq != cf_min_3db_150hz) { + snd_soc_component_write_field( + component, dec_cfg_reg, + cdc_txn_hpf_cut_freq_mask, + hpf_cut_off_freq); + if (is_amic_enabled(component, decimator)) + snd_soc_component_update_bits(component, + hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x02); + else + snd_soc_component_update_bits(component, + hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x03); + + /* + * minimum 1 clk cycle delay is required + * as per hw spec + */ + usleep_range(1000, 1010); + snd_soc_component_update_bits(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x1); + } + } + cancel_delayed_work_sync(&tx->tx_mute_dwork[decimator].dwork); + break; + case snd_soc_dapm_post_pmd: + snd_soc_component_write_field(component, tx_vol_ctl_reg, + cdc_txn_clk_en_mask, 0x0); + snd_soc_component_write_field(component, dec_cfg_reg, + cdc_txn_adc_mode_mask, 0x0); + snd_soc_component_write_field(component, tx_vol_ctl_reg, + cdc_txn_pga_mute_mask, 0x0); + if (tx->bcs_enable) { + snd_soc_component_write_field(component, dec_cfg_reg, + cdc_txn_ph_en_mask, 0x0); + snd_soc_component_write_field(component, + cdc_tx0_tx_path_sec7, + cdc_tx0_mbhc_ctl_en_mask, + 0x0); + tx->bcs_clk_en = false; + } + break; + } + return 0; +} + +static const char * const adc_mux_text[] = { + "msm_dmic", "swr_mic", "anc_fb_tune1" +}; + +static soc_enum_single_decl(tx_dec0_enum, cdc_tx_inp_mux_adc_mux0_cfg1, + 0, adc_mux_text); +static soc_enum_single_decl(tx_dec1_enum, cdc_tx_inp_mux_adc_mux1_cfg1, + 0, adc_mux_text); +static soc_enum_single_decl(tx_dec2_enum, cdc_tx_inp_mux_adc_mux2_cfg1, + 0, adc_mux_text); +static soc_enum_single_decl(tx_dec3_enum, cdc_tx_inp_mux_adc_mux3_cfg1, + 0, adc_mux_text); +static soc_enum_single_decl(tx_dec4_enum, cdc_tx_inp_mux_adc_mux4_cfg1, + 0, adc_mux_text); +static soc_enum_single_decl(tx_dec5_enum, cdc_tx_inp_mux_adc_mux5_cfg1, + 0, adc_mux_text); +static soc_enum_single_decl(tx_dec6_enum, cdc_tx_inp_mux_adc_mux6_cfg1, + 0, adc_mux_text); +static soc_enum_single_decl(tx_dec7_enum, cdc_tx_inp_mux_adc_mux7_cfg1, + 0, adc_mux_text); + +static const struct snd_kcontrol_new tx_dec0_mux = soc_dapm_enum("tx_dec0", tx_dec0_enum); +static const struct snd_kcontrol_new tx_dec1_mux = soc_dapm_enum("tx_dec1", tx_dec1_enum); +static const struct snd_kcontrol_new tx_dec2_mux = soc_dapm_enum("tx_dec2", tx_dec2_enum); +static const struct snd_kcontrol_new tx_dec3_mux = soc_dapm_enum("tx_dec3", tx_dec3_enum); +static const struct snd_kcontrol_new tx_dec4_mux = soc_dapm_enum("tx_dec4", tx_dec4_enum); +static const struct snd_kcontrol_new tx_dec5_mux = soc_dapm_enum("tx_dec5", tx_dec5_enum); +static const struct snd_kcontrol_new tx_dec6_mux = soc_dapm_enum("tx_dec6", tx_dec6_enum); +static const struct snd_kcontrol_new tx_dec7_mux = soc_dapm_enum("tx_dec7", tx_dec7_enum); + +static const char * const smic_mux_text[] = { + "zero", "adc0", "adc1", "adc2", "adc3", "swr_dmic0", + "swr_dmic1", "swr_dmic2", "swr_dmic3", "swr_dmic4", + "swr_dmic5", "swr_dmic6", "swr_dmic7" +}; + +static soc_enum_single_decl(tx_smic0_enum, cdc_tx_inp_mux_adc_mux0_cfg0, + 0, smic_mux_text); + +static soc_enum_single_decl(tx_smic1_enum, cdc_tx_inp_mux_adc_mux1_cfg0, + 0, smic_mux_text); + +static soc_enum_single_decl(tx_smic2_enum, cdc_tx_inp_mux_adc_mux2_cfg0, + 0, smic_mux_text); + +static soc_enum_single_decl(tx_smic3_enum, cdc_tx_inp_mux_adc_mux3_cfg0, + 0, smic_mux_text); + +static soc_enum_single_decl(tx_smic4_enum, cdc_tx_inp_mux_adc_mux4_cfg0, + 0, smic_mux_text); + +static soc_enum_single_decl(tx_smic5_enum, cdc_tx_inp_mux_adc_mux5_cfg0, + 0, smic_mux_text); + +static soc_enum_single_decl(tx_smic6_enum, cdc_tx_inp_mux_adc_mux6_cfg0, + 0, smic_mux_text); + +static soc_enum_single_decl(tx_smic7_enum, cdc_tx_inp_mux_adc_mux7_cfg0, + 0, smic_mux_text); + +static const struct snd_kcontrol_new tx_smic0_mux = soc_dapm_enum_ext("tx_smic0", tx_smic0_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); +static const struct snd_kcontrol_new tx_smic1_mux = soc_dapm_enum_ext("tx_smic1", tx_smic1_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); +static const struct snd_kcontrol_new tx_smic2_mux = soc_dapm_enum_ext("tx_smic2", tx_smic2_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); +static const struct snd_kcontrol_new tx_smic3_mux = soc_dapm_enum_ext("tx_smic3", tx_smic3_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); +static const struct snd_kcontrol_new tx_smic4_mux = soc_dapm_enum_ext("tx_smic4", tx_smic4_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); +static const struct snd_kcontrol_new tx_smic5_mux = soc_dapm_enum_ext("tx_smic5", tx_smic5_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); +static const struct snd_kcontrol_new tx_smic6_mux = soc_dapm_enum_ext("tx_smic6", tx_smic6_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); +static const struct snd_kcontrol_new tx_smic7_mux = soc_dapm_enum_ext("tx_smic7", tx_smic7_enum, + snd_soc_dapm_get_enum_double, tx_macro_put_dec_enum); + +static const struct snd_kcontrol_new tx_aif1_cap_mixer[] = { + soc_single_ext("dec0", snd_soc_nopm, tx_macro_dec0, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec1", snd_soc_nopm, tx_macro_dec1, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec2", snd_soc_nopm, tx_macro_dec2, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec3", snd_soc_nopm, tx_macro_dec3, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec4", snd_soc_nopm, tx_macro_dec4, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec5", snd_soc_nopm, tx_macro_dec5, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec6", snd_soc_nopm, tx_macro_dec6, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec7", snd_soc_nopm, tx_macro_dec7, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), +}; + +static const struct snd_kcontrol_new tx_aif2_cap_mixer[] = { + soc_single_ext("dec0", snd_soc_nopm, tx_macro_dec0, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec1", snd_soc_nopm, tx_macro_dec1, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec2", snd_soc_nopm, tx_macro_dec2, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec3", snd_soc_nopm, tx_macro_dec3, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec4", snd_soc_nopm, tx_macro_dec4, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec5", snd_soc_nopm, tx_macro_dec5, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec6", snd_soc_nopm, tx_macro_dec6, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec7", snd_soc_nopm, tx_macro_dec7, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), +}; + +static const struct snd_kcontrol_new tx_aif3_cap_mixer[] = { + soc_single_ext("dec0", snd_soc_nopm, tx_macro_dec0, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec1", snd_soc_nopm, tx_macro_dec1, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec2", snd_soc_nopm, tx_macro_dec2, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec3", snd_soc_nopm, tx_macro_dec3, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec4", snd_soc_nopm, tx_macro_dec4, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec5", snd_soc_nopm, tx_macro_dec5, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec6", snd_soc_nopm, tx_macro_dec6, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), + soc_single_ext("dec7", snd_soc_nopm, tx_macro_dec7, 1, 0, + tx_macro_tx_mixer_get, tx_macro_tx_mixer_put), +}; + +static const struct snd_soc_dapm_widget tx_macro_dapm_widgets[] = { + snd_soc_dapm_aif_out("tx_aif1 cap", "tx_aif1 capture", 0, + snd_soc_nopm, tx_macro_aif1_cap, 0), + + snd_soc_dapm_aif_out("tx_aif2 cap", "tx_aif2 capture", 0, + snd_soc_nopm, tx_macro_aif2_cap, 0), + + snd_soc_dapm_aif_out("tx_aif3 cap", "tx_aif3 capture", 0, + snd_soc_nopm, tx_macro_aif3_cap, 0), + + snd_soc_dapm_mixer("tx_aif1_cap mixer", snd_soc_nopm, tx_macro_aif1_cap, 0, + tx_aif1_cap_mixer, array_size(tx_aif1_cap_mixer)), + + snd_soc_dapm_mixer("tx_aif2_cap mixer", snd_soc_nopm, tx_macro_aif2_cap, 0, + tx_aif2_cap_mixer, array_size(tx_aif2_cap_mixer)), + + snd_soc_dapm_mixer("tx_aif3_cap mixer", snd_soc_nopm, tx_macro_aif3_cap, 0, + tx_aif3_cap_mixer, array_size(tx_aif3_cap_mixer)), + + snd_soc_dapm_mux("tx smic mux0", snd_soc_nopm, 0, 0, &tx_smic0_mux), + snd_soc_dapm_mux("tx smic mux1", snd_soc_nopm, 0, 0, &tx_smic1_mux), + snd_soc_dapm_mux("tx smic mux2", snd_soc_nopm, 0, 0, &tx_smic2_mux), + snd_soc_dapm_mux("tx smic mux3", snd_soc_nopm, 0, 0, &tx_smic3_mux), + snd_soc_dapm_mux("tx smic mux4", snd_soc_nopm, 0, 0, &tx_smic4_mux), + snd_soc_dapm_mux("tx smic mux5", snd_soc_nopm, 0, 0, &tx_smic5_mux), + snd_soc_dapm_mux("tx smic mux6", snd_soc_nopm, 0, 0, &tx_smic6_mux), + snd_soc_dapm_mux("tx smic mux7", snd_soc_nopm, 0, 0, &tx_smic7_mux), + + snd_soc_dapm_input("tx swr_adc0"), + snd_soc_dapm_input("tx swr_adc1"), + snd_soc_dapm_input("tx swr_adc2"), + snd_soc_dapm_input("tx swr_adc3"), + snd_soc_dapm_input("tx swr_dmic0"), + snd_soc_dapm_input("tx swr_dmic1"), + snd_soc_dapm_input("tx swr_dmic2"), + snd_soc_dapm_input("tx swr_dmic3"), + snd_soc_dapm_input("tx swr_dmic4"), + snd_soc_dapm_input("tx swr_dmic5"), + snd_soc_dapm_input("tx swr_dmic6"), + snd_soc_dapm_input("tx swr_dmic7"), + + snd_soc_dapm_mux_e("tx dec0 mux", snd_soc_nopm, + tx_macro_dec0, 0, + &tx_dec0_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_mux_e("tx dec1 mux", snd_soc_nopm, + tx_macro_dec1, 0, + &tx_dec1_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_mux_e("tx dec2 mux", snd_soc_nopm, + tx_macro_dec2, 0, + &tx_dec2_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_mux_e("tx dec3 mux", snd_soc_nopm, + tx_macro_dec3, 0, + &tx_dec3_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_mux_e("tx dec4 mux", snd_soc_nopm, + tx_macro_dec4, 0, + &tx_dec4_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_mux_e("tx dec5 mux", snd_soc_nopm, + tx_macro_dec5, 0, + &tx_dec5_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_mux_e("tx dec6 mux", snd_soc_nopm, + tx_macro_dec6, 0, + &tx_dec6_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_mux_e("tx dec7 mux", snd_soc_nopm, + tx_macro_dec7, 0, + &tx_dec7_mux, tx_macro_enable_dec, + snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmu | + snd_soc_dapm_pre_pmd | snd_soc_dapm_post_pmd), + + snd_soc_dapm_supply_s("tx_mclk", 0, snd_soc_nopm, 0, 0, + tx_macro_mclk_event, snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd), + + snd_soc_dapm_supply_s("tx_swr_clk", 0, snd_soc_nopm, 0, 0, null, 0), + + snd_soc_dapm_supply_s("va_swr_clk", 0, snd_soc_nopm, 0, 0, + null, 0), +}; + +static const struct snd_soc_dapm_route tx_audio_map[] = { + {"tx_aif1 cap", null, "tx_mclk"}, + {"tx_aif2 cap", null, "tx_mclk"}, + {"tx_aif3 cap", null, "tx_mclk"}, + + {"tx_aif1 cap", null, "tx_aif1_cap mixer"}, + {"tx_aif2 cap", null, "tx_aif2_cap mixer"}, + {"tx_aif3 cap", null, "tx_aif3_cap mixer"}, + + {"tx_aif1_cap mixer", "dec0", "tx dec0 mux"}, + {"tx_aif1_cap mixer", "dec1", "tx dec1 mux"}, + {"tx_aif1_cap mixer", "dec2", "tx dec2 mux"}, + {"tx_aif1_cap mixer", "dec3", "tx dec3 mux"}, + {"tx_aif1_cap mixer", "dec4", "tx dec4 mux"}, + {"tx_aif1_cap mixer", "dec5", "tx dec5 mux"}, + {"tx_aif1_cap mixer", "dec6", "tx dec6 mux"}, + {"tx_aif1_cap mixer", "dec7", "tx dec7 mux"}, + + {"tx_aif2_cap mixer", "dec0", "tx dec0 mux"}, + {"tx_aif2_cap mixer", "dec1", "tx dec1 mux"}, + {"tx_aif2_cap mixer", "dec2", "tx dec2 mux"}, + {"tx_aif2_cap mixer", "dec3", "tx dec3 mux"}, + {"tx_aif2_cap mixer", "dec4", "tx dec4 mux"}, + {"tx_aif2_cap mixer", "dec5", "tx dec5 mux"}, + {"tx_aif2_cap mixer", "dec6", "tx dec6 mux"}, + {"tx_aif2_cap mixer", "dec7", "tx dec7 mux"}, + + {"tx_aif3_cap mixer", "dec0", "tx dec0 mux"}, + {"tx_aif3_cap mixer", "dec1", "tx dec1 mux"}, + {"tx_aif3_cap mixer", "dec2", "tx dec2 mux"}, + {"tx_aif3_cap mixer", "dec3", "tx dec3 mux"}, + {"tx_aif3_cap mixer", "dec4", "tx dec4 mux"}, + {"tx_aif3_cap mixer", "dec5", "tx dec5 mux"}, + {"tx_aif3_cap mixer", "dec6", "tx dec6 mux"}, + {"tx_aif3_cap mixer", "dec7", "tx dec7 mux"}, + + {"tx dec0 mux", null, "tx_mclk"}, + {"tx dec1 mux", null, "tx_mclk"}, + {"tx dec2 mux", null, "tx_mclk"}, + {"tx dec3 mux", null, "tx_mclk"}, + {"tx dec4 mux", null, "tx_mclk"}, + {"tx dec5 mux", null, "tx_mclk"}, + {"tx dec6 mux", null, "tx_mclk"}, + {"tx dec7 mux", null, "tx_mclk"}, + + {"tx dec0 mux", "swr_mic", "tx smic mux0"}, + {"tx smic mux0", null, "tx_swr_clk"}, + {"tx smic mux0", "adc0", "tx swr_adc0"}, + {"tx smic mux0", "adc1", "tx swr_adc1"}, + {"tx smic mux0", "adc2", "tx swr_adc2"}, + {"tx smic mux0", "adc3", "tx swr_adc3"}, + {"tx smic mux0", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux0", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux0", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux0", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux0", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux0", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux0", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux0", "swr_dmic7", "tx swr_dmic7"}, + + {"tx dec1 mux", "swr_mic", "tx smic mux1"}, + {"tx smic mux1", null, "tx_swr_clk"}, + {"tx smic mux1", "adc0", "tx swr_adc0"}, + {"tx smic mux1", "adc1", "tx swr_adc1"}, + {"tx smic mux1", "adc2", "tx swr_adc2"}, + {"tx smic mux1", "adc3", "tx swr_adc3"}, + {"tx smic mux1", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux1", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux1", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux1", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux1", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux1", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux1", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux1", "swr_dmic7", "tx swr_dmic7"}, + + {"tx dec2 mux", "swr_mic", "tx smic mux2"}, + {"tx smic mux2", null, "tx_swr_clk"}, + {"tx smic mux2", "adc0", "tx swr_adc0"}, + {"tx smic mux2", "adc1", "tx swr_adc1"}, + {"tx smic mux2", "adc2", "tx swr_adc2"}, + {"tx smic mux2", "adc3", "tx swr_adc3"}, + {"tx smic mux2", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux2", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux2", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux2", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux2", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux2", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux2", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux2", "swr_dmic7", "tx swr_dmic7"}, + + {"tx dec3 mux", "swr_mic", "tx smic mux3"}, + {"tx smic mux3", null, "tx_swr_clk"}, + {"tx smic mux3", "adc0", "tx swr_adc0"}, + {"tx smic mux3", "adc1", "tx swr_adc1"}, + {"tx smic mux3", "adc2", "tx swr_adc2"}, + {"tx smic mux3", "adc3", "tx swr_adc3"}, + {"tx smic mux3", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux3", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux3", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux3", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux3", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux3", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux3", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux3", "swr_dmic7", "tx swr_dmic7"}, + + {"tx dec4 mux", "swr_mic", "tx smic mux4"}, + {"tx smic mux4", null, "tx_swr_clk"}, + {"tx smic mux4", "adc0", "tx swr_adc0"}, + {"tx smic mux4", "adc1", "tx swr_adc1"}, + {"tx smic mux4", "adc2", "tx swr_adc2"}, + {"tx smic mux4", "adc3", "tx swr_adc3"}, + {"tx smic mux4", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux4", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux4", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux4", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux4", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux4", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux4", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux4", "swr_dmic7", "tx swr_dmic7"}, + + {"tx dec5 mux", "swr_mic", "tx smic mux5"}, + {"tx smic mux5", null, "tx_swr_clk"}, + {"tx smic mux5", "adc0", "tx swr_adc0"}, + {"tx smic mux5", "adc1", "tx swr_adc1"}, + {"tx smic mux5", "adc2", "tx swr_adc2"}, + {"tx smic mux5", "adc3", "tx swr_adc3"}, + {"tx smic mux5", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux5", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux5", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux5", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux5", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux5", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux5", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux5", "swr_dmic7", "tx swr_dmic7"}, + + {"tx dec6 mux", "swr_mic", "tx smic mux6"}, + {"tx smic mux6", null, "tx_swr_clk"}, + {"tx smic mux6", "adc0", "tx swr_adc0"}, + {"tx smic mux6", "adc1", "tx swr_adc1"}, + {"tx smic mux6", "adc2", "tx swr_adc2"}, + {"tx smic mux6", "adc3", "tx swr_adc3"}, + {"tx smic mux6", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux6", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux6", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux6", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux6", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux6", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux6", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux6", "swr_dmic7", "tx swr_dmic7"}, + + {"tx dec7 mux", "swr_mic", "tx smic mux7"}, + {"tx smic mux7", null, "tx_swr_clk"}, + {"tx smic mux7", "adc0", "tx swr_adc0"}, + {"tx smic mux7", "adc1", "tx swr_adc1"}, + {"tx smic mux7", "adc2", "tx swr_adc2"}, + {"tx smic mux7", "adc3", "tx swr_adc3"}, + {"tx smic mux7", "swr_dmic0", "tx swr_dmic0"}, + {"tx smic mux7", "swr_dmic1", "tx swr_dmic1"}, + {"tx smic mux7", "swr_dmic2", "tx swr_dmic2"}, + {"tx smic mux7", "swr_dmic3", "tx swr_dmic3"}, + {"tx smic mux7", "swr_dmic4", "tx swr_dmic4"}, + {"tx smic mux7", "swr_dmic5", "tx swr_dmic5"}, + {"tx smic mux7", "swr_dmic6", "tx swr_dmic6"}, + {"tx smic mux7", "swr_dmic7", "tx swr_dmic7"}, +}; + + .dapm_widgets = tx_macro_dapm_widgets, + .num_dapm_widgets = array_size(tx_macro_dapm_widgets), + .dapm_routes = tx_audio_map, + .num_dapm_routes = array_size(tx_audio_map),
Audio
d207bdea0ca9efde321ff142e9b9f2ef73f9cdf5
srinivas kandagatla
sound
soc
codecs
asoc: codecs: lpass-tx-macro: add support for lpass tx macro
qualcomm lpass (low power audio subsystem) has internal codec tx macro block which is used for connecting with external soundwire tx codecs like wcd938x.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
adds support for two codec macro blocks(tx and rx) available in qualcomm lpass (low power audio subsystem)
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'codecs']
['kconfig', 'c', 'makefile']
3
1,184
0
--- diff --git a/sound/soc/codecs/kconfig b/sound/soc/codecs/kconfig --- a/sound/soc/codecs/kconfig +++ b/sound/soc/codecs/kconfig + imply snd_soc_lpass_tx_macro +config snd_soc_lpass_tx_macro + depends on common_clk + tristate "qualcomm tx macro in lpass(low power audio subsystem)" + diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile +snd-soc-lpass-tx-macro-objs := lpass-tx-macro.o +obj-$(config_snd_soc_lpass_tx_macro) += snd-soc-lpass-tx-macro.o diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c --- /dev/null +++ b/sound/soc/codecs/lpass-tx-macro.c +// spdx-license-identifier: gpl-2.0-only +// copyright (c) 2018-2020, the linux foundation. all rights reserved. + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/tlv.h> +#include <linux/of_clk.h> +#include <linux/clk-provider.h> + +#define cdc_tx_clk_rst_ctrl_mclk_control (0x0000) +#define cdc_tx_mclk_en_mask bit(0) +#define cdc_tx_mclk_enable bit(0) +#define cdc_tx_clk_rst_ctrl_fs_cnt_control (0x0004) +#define cdc_tx_fs_cnt_en_mask bit(0) +#define cdc_tx_fs_cnt_enable bit(0) +#define cdc_tx_clk_rst_ctrl_swr_control (0x0008) +#define cdc_tx_swr_reset_mask bit(1) +#define cdc_tx_swr_reset_enable bit(1) +#define cdc_tx_swr_clk_en_mask bit(0) +#define cdc_tx_swr_clk_enable bit(0) +#define cdc_tx_top_csr_top_cfg0 (0x0080) +#define cdc_tx_top_csr_anc_cfg (0x0084) +#define cdc_tx_top_csr_swr_ctrl (0x0088) +#define cdc_tx_top_csr_freq_mclk (0x0090) +#define cdc_tx_top_csr_debug_bus (0x0094) +#define cdc_tx_top_csr_debug_en (0x0098) +#define cdc_tx_top_csr_tx_i2s_ctl (0x00a4) +#define cdc_tx_top_csr_i2s_clk (0x00a8) +#define cdc_tx_top_csr_i2s_reset (0x00ac) +#define cdc_tx_top_csr_swr_dmicn_ctl(n) (0x00c0 + n * 0x4) +#define cdc_tx_top_csr_swr_dmic0_ctl (0x00c0) +#define cdc_tx_swr_dmic_clk_sel_mask genmask(3, 1) +#define cdc_tx_top_csr_swr_dmic1_ctl (0x00c4) +#define cdc_tx_top_csr_swr_dmic2_ctl (0x00c8) +#define cdc_tx_top_csr_swr_dmic3_ctl (0x00cc) +#define cdc_tx_top_csr_swr_amic0_ctl (0x00d0) +#define cdc_tx_top_csr_swr_amic1_ctl (0x00d4) +#define cdc_tx_inp_mux_adc_muxn_cfg0(n) (0x0100 + 0x8 * n) +#define cdc_tx_macro_swr_mic_mux_sel_mask genmask(3, 0) +#define cdc_tx_inp_mux_adc_mux0_cfg0 (0x0100) +#define cdc_tx_inp_mux_adc_muxn_cfg1(n) (0x0104 + 0x8 * n) +#define cdc_tx_inp_mux_adc_mux0_cfg1 (0x0104) +#define cdc_tx_inp_mux_adc_mux1_cfg0 (0x0108) +#define cdc_tx_inp_mux_adc_mux1_cfg1 (0x010c) +#define cdc_tx_inp_mux_adc_mux2_cfg0 (0x0110) +#define cdc_tx_inp_mux_adc_mux2_cfg1 (0x0114) +#define cdc_tx_inp_mux_adc_mux3_cfg0 (0x0118) +#define cdc_tx_inp_mux_adc_mux3_cfg1 (0x011c) +#define cdc_tx_inp_mux_adc_mux4_cfg0 (0x0120) +#define cdc_tx_inp_mux_adc_mux4_cfg1 (0x0124) +#define cdc_tx_inp_mux_adc_mux5_cfg0 (0x0128) +#define cdc_tx_inp_mux_adc_mux5_cfg1 (0x012c) +#define cdc_tx_inp_mux_adc_mux6_cfg0 (0x0130) +#define cdc_tx_inp_mux_adc_mux6_cfg1 (0x0134) +#define cdc_tx_inp_mux_adc_mux7_cfg0 (0x0138) +#define cdc_tx_inp_mux_adc_mux7_cfg1 (0x013c) +#define cdc_tx_anc0_clk_reset_ctl (0x0200) +#define cdc_tx_anc0_mode_1_ctl (0x0204) +#define cdc_tx_anc0_mode_2_ctl (0x0208) +#define cdc_tx_anc0_ff_shift (0x020c) +#define cdc_tx_anc0_fb_shift (0x0210) +#define cdc_tx_anc0_lpf_ff_a_ctl (0x0214) +#define cdc_tx_anc0_lpf_ff_b_ctl (0x0218) +#define cdc_tx_anc0_lpf_fb_ctl (0x021c) +#define cdc_tx_anc0_smlpf_ctl (0x0220) +#define cdc_tx_anc0_dcflt_shift_ctl (0x0224) +#define cdc_tx_anc0_iir_adapt_ctl (0x0228) +#define cdc_tx_anc0_iir_coeff_1_ctl (0x022c) +#define cdc_tx_anc0_iir_coeff_2_ctl (0x0230) +#define cdc_tx_anc0_ff_a_gain_ctl (0x0234) +#define cdc_tx_anc0_ff_b_gain_ctl (0x0238) +#define cdc_tx_anc0_fb_gain_ctl (0x023c) +#define cdc_txn_tx_path_ctl(n) (0x0400 + 0x80 * n) +#define cdc_txn_pcm_rate_mask genmask(3, 0) +#define cdc_txn_pga_mute_mask bit(4) +#define cdc_txn_clk_en_mask bit(5) +#define cdc_tx0_tx_path_ctl (0x0400) +#define cdc_txn_tx_path_cfg0(n) (0x0404 + 0x80 * n) +#define cdc_tx0_tx_path_cfg0 (0x0404) +#define cdc_txn_ph_en_mask bit(0) +#define cdc_txn_adc_mode_mask genmask(2, 1) +#define cdc_txn_hpf_cut_freq_mask genmask(6, 5) +#define cdc_txn_adc_dmic_sel_mask bit(7) +#define cdc_tx0_tx_path_cfg1 (0x0408) +#define cdc_txn_tx_vol_ctl(n) (0x040c + 0x80 * n) +#define cdc_tx0_tx_vol_ctl (0x040c) +#define cdc_tx0_tx_path_sec0 (0x0410) +#define cdc_tx0_tx_path_sec1 (0x0414) +#define cdc_txn_tx_path_sec2(n) (0x0418 + 0x80 * n) +#define cdc_txn_hpf_f_change_mask bit(1) +#define cdc_txn_hpf_zero_gate_mask bit(0) +#define cdc_tx0_tx_path_sec2 (0x0418) +#define cdc_tx0_tx_path_sec3 (0x041c) +#define cdc_tx0_tx_path_sec4 (0x0420) +#define cdc_tx0_tx_path_sec5 (0x0424) +#define cdc_tx0_tx_path_sec6 (0x0428) +#define cdc_tx0_tx_path_sec7 (0x042c) +#define cdc_tx0_mbhc_ctl_en_mask bit(6) +#define cdc_tx1_tx_path_ctl (0x0480) +#define cdc_tx1_tx_path_cfg0 (0x0484) +#define cdc_tx1_tx_path_cfg1 (0x0488) +#define cdc_tx1_tx_vol_ctl (0x048c) +#define cdc_tx1_tx_path_sec0 (0x0490) +#define cdc_tx1_tx_path_sec1 (0x0494) +#define cdc_tx1_tx_path_sec2 (0x0498) +#define cdc_tx1_tx_path_sec3 (0x049c) +#define cdc_tx1_tx_path_sec4 (0x04a0) +#define cdc_tx1_tx_path_sec5 (0x04a4) +#define cdc_tx1_tx_path_sec6 (0x04a8) +#define cdc_tx2_tx_path_ctl (0x0500) +#define cdc_tx2_tx_path_cfg0 (0x0504) +#define cdc_tx2_tx_path_cfg1 (0x0508) +#define cdc_tx2_tx_vol_ctl (0x050c) +#define cdc_tx2_tx_path_sec0 (0x0510) +#define cdc_tx2_tx_path_sec1 (0x0514) +#define cdc_tx2_tx_path_sec2 (0x0518) +#define cdc_tx2_tx_path_sec3 (0x051c) +#define cdc_tx2_tx_path_sec4 (0x0520) +#define cdc_tx2_tx_path_sec5 (0x0524) +#define cdc_tx2_tx_path_sec6 (0x0528) +#define cdc_tx3_tx_path_ctl (0x0580) +#define cdc_tx3_tx_path_cfg0 (0x0584) +#define cdc_tx3_tx_path_cfg1 (0x0588) +#define cdc_tx3_tx_vol_ctl (0x058c) +#define cdc_tx3_tx_path_sec0 (0x0590) +#define cdc_tx3_tx_path_sec1 (0x0594) +#define cdc_tx3_tx_path_sec2 (0x0598) +#define cdc_tx3_tx_path_sec3 (0x059c) +#define cdc_tx3_tx_path_sec4 (0x05a0) +#define cdc_tx3_tx_path_sec5 (0x05a4) +#define cdc_tx3_tx_path_sec6 (0x05a8) +#define cdc_tx4_tx_path_ctl (0x0600) +#define cdc_tx4_tx_path_cfg0 (0x0604) +#define cdc_tx4_tx_path_cfg1 (0x0608) +#define cdc_tx4_tx_vol_ctl (0x060c) +#define cdc_tx4_tx_path_sec0 (0x0610) +#define cdc_tx4_tx_path_sec1 (0x0614) +#define cdc_tx4_tx_path_sec2 (0x0618) +#define cdc_tx4_tx_path_sec3 (0x061c) +#define cdc_tx4_tx_path_sec4 (0x0620) +#define cdc_tx4_tx_path_sec5 (0x0624) +#define cdc_tx4_tx_path_sec6 (0x0628) +#define cdc_tx5_tx_path_ctl (0x0680) +#define cdc_tx5_tx_path_cfg0 (0x0684) +#define cdc_tx5_tx_path_cfg1 (0x0688) +#define cdc_tx5_tx_vol_ctl (0x068c) +#define cdc_tx5_tx_path_sec0 (0x0690) +#define cdc_tx5_tx_path_sec1 (0x0694) +#define cdc_tx5_tx_path_sec2 (0x0698) +#define cdc_tx5_tx_path_sec3 (0x069c) +#define cdc_tx5_tx_path_sec4 (0x06a0) +#define cdc_tx5_tx_path_sec5 (0x06a4) +#define cdc_tx5_tx_path_sec6 (0x06a8) +#define cdc_tx6_tx_path_ctl (0x0700) +#define cdc_tx6_tx_path_cfg0 (0x0704) +#define cdc_tx6_tx_path_cfg1 (0x0708) +#define cdc_tx6_tx_vol_ctl (0x070c) +#define cdc_tx6_tx_path_sec0 (0x0710) +#define cdc_tx6_tx_path_sec1 (0x0714) +#define cdc_tx6_tx_path_sec2 (0x0718) +#define cdc_tx6_tx_path_sec3 (0x071c) +#define cdc_tx6_tx_path_sec4 (0x0720) +#define cdc_tx6_tx_path_sec5 (0x0724) +#define cdc_tx6_tx_path_sec6 (0x0728) +#define cdc_tx7_tx_path_ctl (0x0780) +#define cdc_tx7_tx_path_cfg0 (0x0784) +#define cdc_tx7_tx_path_cfg1 (0x0788) +#define cdc_tx7_tx_vol_ctl (0x078c) +#define cdc_tx7_tx_path_sec0 (0x0790) +#define cdc_tx7_tx_path_sec1 (0x0794) +#define cdc_tx7_tx_path_sec2 (0x0798) +#define cdc_tx7_tx_path_sec3 (0x079c) +#define cdc_tx7_tx_path_sec4 (0x07a0) +#define cdc_tx7_tx_path_sec5 (0x07a4) +#define cdc_tx7_tx_path_sec6 (0x07a8) +#define tx_max_offset (0x07a8) + +#define tx_macro_rates (sndrv_pcm_rate_8000 | sndrv_pcm_rate_16000 |\ + sndrv_pcm_rate_32000 | sndrv_pcm_rate_48000 |\ + sndrv_pcm_rate_96000 | sndrv_pcm_rate_192000) +#define tx_macro_formats (sndrv_pcm_fmtbit_s16_le |\ + sndrv_pcm_fmtbit_s24_le |\ + sndrv_pcm_fmtbit_s24_3le) + +#define cf_min_3db_4hz 0x0 +#define cf_min_3db_75hz 0x1 +#define cf_min_3db_150hz 0x2 +#define tx_adc_max 5 +#define tx_adc_to_dmic(n) ((n - tx_adc_max)/2) +#define num_decimators 8 +#define tx_num_clks_max 5 +#define tx_macro_dmic_unmute_delay_ms 40 +#define tx_macro_amic_unmute_delay_ms 100 +#define tx_macro_dmic_hpf_delay_ms 300 +#define tx_macro_amic_hpf_delay_ms 300 +#define mclk_freq 9600000 + +enum { + tx_macro_aif_invalid = 0, + tx_macro_aif1_cap, + tx_macro_aif2_cap, + tx_macro_aif3_cap, + tx_macro_max_dais +}; + +enum { + tx_macro_dec0, + tx_macro_dec1, + tx_macro_dec2, + tx_macro_dec3, + tx_macro_dec4, + tx_macro_dec5, + tx_macro_dec6, + tx_macro_dec7, + tx_macro_dec_max, +}; + +enum { + tx_macro_clk_div_2, + tx_macro_clk_div_3, + tx_macro_clk_div_4, + tx_macro_clk_div_6, + tx_macro_clk_div_8, + tx_macro_clk_div_16, +}; + +enum { + msm_dmic, + swr_mic, + anc_fb_tune1 +}; + +struct tx_mute_work { + struct tx_macro *tx; + u32 decimator; + struct delayed_work dwork; +}; + +struct hpf_work { + struct tx_macro *tx; + u8 decimator; + u8 hpf_cut_off_freq; + struct delayed_work dwork; +}; + +struct tx_macro { + struct device *dev; + struct snd_soc_component *component; + struct hpf_work tx_hpf_work[num_decimators]; + struct tx_mute_work tx_mute_dwork[num_decimators]; + unsigned long active_ch_mask[tx_macro_max_dais]; + unsigned long active_ch_cnt[tx_macro_max_dais]; + unsigned long active_decimator[tx_macro_max_dais]; + struct regmap *regmap; + struct clk_bulk_data clks[tx_num_clks_max]; + struct clk_hw hw; + bool dec_active[num_decimators]; + bool reset_swr; + int tx_mclk_users; + u16 dmic_clk_div; + bool bcs_enable; + int dec_mode[num_decimators]; + bool bcs_clk_en; +}; +#define to_tx_macro(_hw) container_of(_hw, struct tx_macro, hw) + +static const declare_tlv_db_scale(digital_gain, -8400, 100, -8400); + +static const struct reg_default tx_defaults[] = { + /* tx macro */ + { cdc_tx_clk_rst_ctrl_mclk_control, 0x00 }, + { cdc_tx_clk_rst_ctrl_fs_cnt_control, 0x00 }, + { cdc_tx_clk_rst_ctrl_swr_control, 0x00}, + { cdc_tx_top_csr_top_cfg0, 0x00}, + { cdc_tx_top_csr_anc_cfg, 0x00}, + { cdc_tx_top_csr_swr_ctrl, 0x00}, + { cdc_tx_top_csr_freq_mclk, 0x00}, + { cdc_tx_top_csr_debug_bus, 0x00}, + { cdc_tx_top_csr_debug_en, 0x00}, + { cdc_tx_top_csr_tx_i2s_ctl, 0x0c}, + { cdc_tx_top_csr_i2s_clk, 0x00}, + { cdc_tx_top_csr_i2s_reset, 0x00}, + { cdc_tx_top_csr_swr_dmic0_ctl, 0x00}, + { cdc_tx_top_csr_swr_dmic1_ctl, 0x00}, + { cdc_tx_top_csr_swr_dmic2_ctl, 0x00}, + { cdc_tx_top_csr_swr_dmic3_ctl, 0x00}, + { cdc_tx_top_csr_swr_amic0_ctl, 0x00}, + { cdc_tx_top_csr_swr_amic1_ctl, 0x00}, + { cdc_tx_inp_mux_adc_mux0_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux0_cfg1, 0x00}, + { cdc_tx_inp_mux_adc_mux1_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux1_cfg1, 0x00}, + { cdc_tx_inp_mux_adc_mux2_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux2_cfg1, 0x00}, + { cdc_tx_inp_mux_adc_mux3_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux3_cfg1, 0x00}, + { cdc_tx_inp_mux_adc_mux4_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux4_cfg1, 0x00}, + { cdc_tx_inp_mux_adc_mux5_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux5_cfg1, 0x00}, + { cdc_tx_inp_mux_adc_mux6_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux6_cfg1, 0x00}, + { cdc_tx_inp_mux_adc_mux7_cfg0, 0x00}, + { cdc_tx_inp_mux_adc_mux7_cfg1, 0x00}, + { cdc_tx_anc0_clk_reset_ctl, 0x00}, + { cdc_tx_anc0_mode_1_ctl, 0x00}, + { cdc_tx_anc0_mode_2_ctl, 0x00}, + { cdc_tx_anc0_ff_shift, 0x00}, + { cdc_tx_anc0_fb_shift, 0x00}, + { cdc_tx_anc0_lpf_ff_a_ctl, 0x00}, + { cdc_tx_anc0_lpf_ff_b_ctl, 0x00}, + { cdc_tx_anc0_lpf_fb_ctl, 0x00}, + { cdc_tx_anc0_smlpf_ctl, 0x00}, + { cdc_tx_anc0_dcflt_shift_ctl, 0x00}, + { cdc_tx_anc0_iir_adapt_ctl, 0x00}, + { cdc_tx_anc0_iir_coeff_1_ctl, 0x00}, + { cdc_tx_anc0_iir_coeff_2_ctl, 0x00}, + { cdc_tx_anc0_ff_a_gain_ctl, 0x00}, + { cdc_tx_anc0_ff_b_gain_ctl, 0x00}, + { cdc_tx_anc0_fb_gain_ctl, 0x00}, + { cdc_tx0_tx_path_ctl, 0x04}, + { cdc_tx0_tx_path_cfg0, 0x10}, + { cdc_tx0_tx_path_cfg1, 0x0b}, + { cdc_tx0_tx_vol_ctl, 0x00}, + { cdc_tx0_tx_path_sec0, 0x00}, + { cdc_tx0_tx_path_sec1, 0x00}, + { cdc_tx0_tx_path_sec2, 0x01}, + { cdc_tx0_tx_path_sec3, 0x3c}, + { cdc_tx0_tx_path_sec4, 0x20}, + { cdc_tx0_tx_path_sec5, 0x00}, + { cdc_tx0_tx_path_sec6, 0x00}, + { cdc_tx0_tx_path_sec7, 0x25}, + { cdc_tx1_tx_path_ctl, 0x04}, + { cdc_tx1_tx_path_cfg0, 0x10}, + { cdc_tx1_tx_path_cfg1, 0x0b}, + { cdc_tx1_tx_vol_ctl, 0x00}, + { cdc_tx1_tx_path_sec0, 0x00}, + { cdc_tx1_tx_path_sec1, 0x00}, + { cdc_tx1_tx_path_sec2, 0x01}, + { cdc_tx1_tx_path_sec3, 0x3c}, + { cdc_tx1_tx_path_sec4, 0x20}, + { cdc_tx1_tx_path_sec5, 0x00}, + { cdc_tx1_tx_path_sec6, 0x00}, + { cdc_tx2_tx_path_ctl, 0x04}, + { cdc_tx2_tx_path_cfg0, 0x10}, + { cdc_tx2_tx_path_cfg1, 0x0b}, + { cdc_tx2_tx_vol_ctl, 0x00}, + { cdc_tx2_tx_path_sec0, 0x00}, + { cdc_tx2_tx_path_sec1, 0x00}, + { cdc_tx2_tx_path_sec2, 0x01}, + { cdc_tx2_tx_path_sec3, 0x3c}, + { cdc_tx2_tx_path_sec4, 0x20}, + { cdc_tx2_tx_path_sec5, 0x00}, + { cdc_tx2_tx_path_sec6, 0x00}, + { cdc_tx3_tx_path_ctl, 0x04}, + { cdc_tx3_tx_path_cfg0, 0x10}, + { cdc_tx3_tx_path_cfg1, 0x0b}, + { cdc_tx3_tx_vol_ctl, 0x00}, + { cdc_tx3_tx_path_sec0, 0x00}, + { cdc_tx3_tx_path_sec1, 0x00}, + { cdc_tx3_tx_path_sec2, 0x01}, + { cdc_tx3_tx_path_sec3, 0x3c}, + { cdc_tx3_tx_path_sec4, 0x20}, + { cdc_tx3_tx_path_sec5, 0x00}, + { cdc_tx3_tx_path_sec6, 0x00}, + { cdc_tx4_tx_path_ctl, 0x04}, + { cdc_tx4_tx_path_cfg0, 0x10}, + { cdc_tx4_tx_path_cfg1, 0x0b}, + { cdc_tx4_tx_vol_ctl, 0x00}, + { cdc_tx4_tx_path_sec0, 0x00}, + { cdc_tx4_tx_path_sec1, 0x00}, + { cdc_tx4_tx_path_sec2, 0x01}, + { cdc_tx4_tx_path_sec3, 0x3c}, + { cdc_tx4_tx_path_sec4, 0x20}, + { cdc_tx4_tx_path_sec5, 0x00}, + { cdc_tx4_tx_path_sec6, 0x00}, + { cdc_tx5_tx_path_ctl, 0x04}, + { cdc_tx5_tx_path_cfg0, 0x10}, + { cdc_tx5_tx_path_cfg1, 0x0b}, + { cdc_tx5_tx_vol_ctl, 0x00}, + { cdc_tx5_tx_path_sec0, 0x00}, + { cdc_tx5_tx_path_sec1, 0x00}, + { cdc_tx5_tx_path_sec2, 0x01}, + { cdc_tx5_tx_path_sec3, 0x3c}, + { cdc_tx5_tx_path_sec4, 0x20}, + { cdc_tx5_tx_path_sec5, 0x00}, + { cdc_tx5_tx_path_sec6, 0x00}, + { cdc_tx6_tx_path_ctl, 0x04}, + { cdc_tx6_tx_path_cfg0, 0x10}, + { cdc_tx6_tx_path_cfg1, 0x0b}, + { cdc_tx6_tx_vol_ctl, 0x00}, + { cdc_tx6_tx_path_sec0, 0x00}, + { cdc_tx6_tx_path_sec1, 0x00}, + { cdc_tx6_tx_path_sec2, 0x01}, + { cdc_tx6_tx_path_sec3, 0x3c}, + { cdc_tx6_tx_path_sec4, 0x20}, + { cdc_tx6_tx_path_sec5, 0x00}, + { cdc_tx6_tx_path_sec6, 0x00}, + { cdc_tx7_tx_path_ctl, 0x04}, + { cdc_tx7_tx_path_cfg0, 0x10}, + { cdc_tx7_tx_path_cfg1, 0x0b}, + { cdc_tx7_tx_vol_ctl, 0x00}, + { cdc_tx7_tx_path_sec0, 0x00}, + { cdc_tx7_tx_path_sec1, 0x00}, + { cdc_tx7_tx_path_sec2, 0x01}, + { cdc_tx7_tx_path_sec3, 0x3c}, + { cdc_tx7_tx_path_sec4, 0x20}, + { cdc_tx7_tx_path_sec5, 0x00}, + { cdc_tx7_tx_path_sec6, 0x00}, +}; + +static bool tx_is_volatile_register(struct device *dev, unsigned int reg) +{ + /* update volatile list for tx/tx macros */ + switch (reg) { + case cdc_tx_top_csr_swr_dmic0_ctl: + case cdc_tx_top_csr_swr_dmic1_ctl: + case cdc_tx_top_csr_swr_dmic2_ctl: + case cdc_tx_top_csr_swr_dmic3_ctl: + return true; + } + return false; +} + +static bool tx_is_rw_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case cdc_tx_clk_rst_ctrl_mclk_control: + case cdc_tx_clk_rst_ctrl_fs_cnt_control: + case cdc_tx_clk_rst_ctrl_swr_control: + case cdc_tx_top_csr_top_cfg0: + case cdc_tx_top_csr_anc_cfg: + case cdc_tx_top_csr_swr_ctrl: + case cdc_tx_top_csr_freq_mclk: + case cdc_tx_top_csr_debug_bus: + case cdc_tx_top_csr_debug_en: + case cdc_tx_top_csr_tx_i2s_ctl: + case cdc_tx_top_csr_i2s_clk: + case cdc_tx_top_csr_i2s_reset: + case cdc_tx_top_csr_swr_dmic0_ctl: + case cdc_tx_top_csr_swr_dmic1_ctl: + case cdc_tx_top_csr_swr_dmic2_ctl: + case cdc_tx_top_csr_swr_dmic3_ctl: + case cdc_tx_top_csr_swr_amic0_ctl: + case cdc_tx_top_csr_swr_amic1_ctl: + case cdc_tx_anc0_clk_reset_ctl: + case cdc_tx_anc0_mode_1_ctl: + case cdc_tx_anc0_mode_2_ctl: + case cdc_tx_anc0_ff_shift: + case cdc_tx_anc0_fb_shift: + case cdc_tx_anc0_lpf_ff_a_ctl: + case cdc_tx_anc0_lpf_ff_b_ctl: + case cdc_tx_anc0_lpf_fb_ctl: + case cdc_tx_anc0_smlpf_ctl: + case cdc_tx_anc0_dcflt_shift_ctl: + case cdc_tx_anc0_iir_adapt_ctl: + case cdc_tx_anc0_iir_coeff_1_ctl: + case cdc_tx_anc0_iir_coeff_2_ctl: + case cdc_tx_anc0_ff_a_gain_ctl: + case cdc_tx_anc0_ff_b_gain_ctl: + case cdc_tx_anc0_fb_gain_ctl: + case cdc_tx_inp_mux_adc_mux0_cfg0: + case cdc_tx_inp_mux_adc_mux0_cfg1: + case cdc_tx_inp_mux_adc_mux1_cfg0: + case cdc_tx_inp_mux_adc_mux1_cfg1: + case cdc_tx_inp_mux_adc_mux2_cfg0: + case cdc_tx_inp_mux_adc_mux2_cfg1: + case cdc_tx_inp_mux_adc_mux3_cfg0: + case cdc_tx_inp_mux_adc_mux3_cfg1: + case cdc_tx_inp_mux_adc_mux4_cfg0: + case cdc_tx_inp_mux_adc_mux4_cfg1: + case cdc_tx_inp_mux_adc_mux5_cfg0: + case cdc_tx_inp_mux_adc_mux5_cfg1: + case cdc_tx_inp_mux_adc_mux6_cfg0: + case cdc_tx_inp_mux_adc_mux6_cfg1: + case cdc_tx_inp_mux_adc_mux7_cfg0: + case cdc_tx_inp_mux_adc_mux7_cfg1: + case cdc_tx0_tx_path_ctl: + case cdc_tx0_tx_path_cfg0: + case cdc_tx0_tx_path_cfg1: + case cdc_tx0_tx_vol_ctl: + case cdc_tx0_tx_path_sec0: + case cdc_tx0_tx_path_sec1: + case cdc_tx0_tx_path_sec2: + case cdc_tx0_tx_path_sec3: + case cdc_tx0_tx_path_sec4: + case cdc_tx0_tx_path_sec5: + case cdc_tx0_tx_path_sec6: + case cdc_tx0_tx_path_sec7: + case cdc_tx1_tx_path_ctl: + case cdc_tx1_tx_path_cfg0: + case cdc_tx1_tx_path_cfg1: + case cdc_tx1_tx_vol_ctl: + case cdc_tx1_tx_path_sec0: + case cdc_tx1_tx_path_sec1: + case cdc_tx1_tx_path_sec2: + case cdc_tx1_tx_path_sec3: + case cdc_tx1_tx_path_sec4: + case cdc_tx1_tx_path_sec5: + case cdc_tx1_tx_path_sec6: + case cdc_tx2_tx_path_ctl: + case cdc_tx2_tx_path_cfg0: + case cdc_tx2_tx_path_cfg1: + case cdc_tx2_tx_vol_ctl: + case cdc_tx2_tx_path_sec0: + case cdc_tx2_tx_path_sec1: + case cdc_tx2_tx_path_sec2: + case cdc_tx2_tx_path_sec3: + case cdc_tx2_tx_path_sec4: + case cdc_tx2_tx_path_sec5: + case cdc_tx2_tx_path_sec6: + case cdc_tx3_tx_path_ctl: + case cdc_tx3_tx_path_cfg0: + case cdc_tx3_tx_path_cfg1: + case cdc_tx3_tx_vol_ctl: + case cdc_tx3_tx_path_sec0: + case cdc_tx3_tx_path_sec1: + case cdc_tx3_tx_path_sec2: + case cdc_tx3_tx_path_sec3: + case cdc_tx3_tx_path_sec4: + case cdc_tx3_tx_path_sec5: + case cdc_tx3_tx_path_sec6: + case cdc_tx4_tx_path_ctl: + case cdc_tx4_tx_path_cfg0: + case cdc_tx4_tx_path_cfg1: + case cdc_tx4_tx_vol_ctl: + case cdc_tx4_tx_path_sec0: + case cdc_tx4_tx_path_sec1: + case cdc_tx4_tx_path_sec2: + case cdc_tx4_tx_path_sec3: + case cdc_tx4_tx_path_sec4: + case cdc_tx4_tx_path_sec5: + case cdc_tx4_tx_path_sec6: + case cdc_tx5_tx_path_ctl: + case cdc_tx5_tx_path_cfg0: + case cdc_tx5_tx_path_cfg1: + case cdc_tx5_tx_vol_ctl: + case cdc_tx5_tx_path_sec0: + case cdc_tx5_tx_path_sec1: + case cdc_tx5_tx_path_sec2: + case cdc_tx5_tx_path_sec3: + case cdc_tx5_tx_path_sec4: + case cdc_tx5_tx_path_sec5: + case cdc_tx5_tx_path_sec6: + case cdc_tx6_tx_path_ctl: + case cdc_tx6_tx_path_cfg0: + case cdc_tx6_tx_path_cfg1: + case cdc_tx6_tx_vol_ctl: + case cdc_tx6_tx_path_sec0: + case cdc_tx6_tx_path_sec1: + case cdc_tx6_tx_path_sec2: + case cdc_tx6_tx_path_sec3: + case cdc_tx6_tx_path_sec4: + case cdc_tx6_tx_path_sec5: + case cdc_tx6_tx_path_sec6: + case cdc_tx7_tx_path_ctl: + case cdc_tx7_tx_path_cfg0: + case cdc_tx7_tx_path_cfg1: + case cdc_tx7_tx_vol_ctl: + case cdc_tx7_tx_path_sec0: + case cdc_tx7_tx_path_sec1: + case cdc_tx7_tx_path_sec2: + case cdc_tx7_tx_path_sec3: + case cdc_tx7_tx_path_sec4: + case cdc_tx7_tx_path_sec5: + case cdc_tx7_tx_path_sec6: + return true; + } + + return false; +} + +static const struct regmap_config tx_regmap_config = { + .name = "tx_macro", + .reg_bits = 16, + .val_bits = 32, + .reg_stride = 4, + .cache_type = regcache_flat, + .max_register = tx_max_offset, + .reg_defaults = tx_defaults, + .num_reg_defaults = array_size(tx_defaults), + .writeable_reg = tx_is_rw_register, + .volatile_reg = tx_is_volatile_register, + .readable_reg = tx_is_rw_register, +}; + +static int tx_macro_mclk_enable(struct tx_macro *tx, + bool mclk_enable) +{ + struct regmap *regmap = tx->regmap; + + if (mclk_enable) { + if (tx->tx_mclk_users == 0) { + /* 9.6mhz mclk, set value 0x00 if other frequency */ + regmap_update_bits(regmap, cdc_tx_top_csr_freq_mclk, 0x01, 0x01); + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_mclk_control, + cdc_tx_mclk_en_mask, + cdc_tx_mclk_enable); + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_fs_cnt_control, + cdc_tx_fs_cnt_en_mask, + cdc_tx_fs_cnt_enable); + regcache_mark_dirty(regmap); + regcache_sync(regmap); + } + tx->tx_mclk_users++; + } else { + if (tx->tx_mclk_users <= 0) { + dev_err(tx->dev, "clock already disabled "); + tx->tx_mclk_users = 0; + goto exit; + } + tx->tx_mclk_users--; + if (tx->tx_mclk_users == 0) { + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_fs_cnt_control, + cdc_tx_fs_cnt_en_mask, 0x0); + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_mclk_control, + cdc_tx_mclk_en_mask, 0x0); + } + } +exit: + return 0; +} + +static bool is_amic_enabled(struct snd_soc_component *component, int decimator) +{ + u16 adc_mux_reg, adc_reg, adc_n; + + adc_mux_reg = cdc_tx_inp_mux_adc_muxn_cfg1(decimator); + + if (snd_soc_component_read(component, adc_mux_reg) & swr_mic) { + adc_reg = cdc_tx_inp_mux_adc_muxn_cfg0(decimator); + adc_n = snd_soc_component_read_field(component, adc_reg, + cdc_tx_macro_swr_mic_mux_sel_mask); + if (adc_n < tx_adc_max) + return true; + } + + return false; +} + +static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work) +{ + struct delayed_work *hpf_delayed_work; + struct hpf_work *hpf_work; + struct tx_macro *tx; + struct snd_soc_component *component; + u16 dec_cfg_reg, hpf_gate_reg; + u8 hpf_cut_off_freq; + + hpf_delayed_work = to_delayed_work(work); + hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); + tx = hpf_work->tx; + component = tx->component; + hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; + + dec_cfg_reg = cdc_txn_tx_path_cfg0(hpf_work->decimator); + hpf_gate_reg = cdc_txn_tx_path_sec2(hpf_work->decimator); + + if (is_amic_enabled(component, hpf_work->decimator)) { + snd_soc_component_write_field(component, + dec_cfg_reg, + cdc_txn_hpf_cut_freq_mask, + hpf_cut_off_freq); + snd_soc_component_update_bits(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x02); + snd_soc_component_update_bits(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask | + cdc_txn_hpf_zero_gate_mask, + 0x01); + } else { + snd_soc_component_write_field(component, dec_cfg_reg, + cdc_txn_hpf_cut_freq_mask, + hpf_cut_off_freq); + snd_soc_component_write_field(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask, 0x1); + /* minimum 1 clk cycle delay is required as per hw spec */ + usleep_range(1000, 1010); + snd_soc_component_write_field(component, hpf_gate_reg, + cdc_txn_hpf_f_change_mask, 0x0); + } +} + +static void tx_macro_mute_update_callback(struct work_struct *work) +{ + struct tx_mute_work *tx_mute_dwork; + struct snd_soc_component *component; + struct tx_macro *tx; + struct delayed_work *delayed_work; + u8 decimator; + + delayed_work = to_delayed_work(work); + tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork); + tx = tx_mute_dwork->tx; + component = tx->component; + decimator = tx_mute_dwork->decimator; + + snd_soc_component_write_field(component, cdc_txn_tx_path_ctl(decimator), + cdc_txn_pga_mute_mask, 0x0); +} + +static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + int path = e->shift_l; + + ucontrol->value.integer.value[0] = tx->dec_mode[path]; + + return 0; +} + +static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + int value = ucontrol->value.integer.value[0]; + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + int path = e->shift_l; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + tx->dec_mode[path] = value; + + return 0; +} + +static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = tx->bcs_enable; + + return 0; +} + +static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + int value = ucontrol->value.integer.value[0]; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + tx->bcs_enable = value; + + return 0; +} + +static int tx_macro_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; + u32 decimator, sample_rate; + int tx_fs_rate; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + sample_rate = params_rate(params); + switch (sample_rate) { + case 8000: + tx_fs_rate = 0; + break; + case 16000: + tx_fs_rate = 1; + break; + case 32000: + tx_fs_rate = 3; + break; + case 48000: + tx_fs_rate = 4; + break; + case 96000: + tx_fs_rate = 5; + break; + case 192000: + tx_fs_rate = 6; + break; + case 384000: + tx_fs_rate = 7; + break; + default: + dev_err(component->dev, "%s: invalid tx sample rate: %d ", + __func__, params_rate(params)); + return -einval; + } + + for_each_set_bit(decimator, &tx->active_ch_mask[dai->id], tx_macro_dec_max) + snd_soc_component_update_bits(component, cdc_txn_tx_path_ctl(decimator), + cdc_txn_pcm_rate_mask, + tx_fs_rate); + return 0; +} + +static int tx_macro_get_channel_map(struct snd_soc_dai *dai, + unsigned int *tx_num, unsigned int *tx_slot, + unsigned int *rx_num, unsigned int *rx_slot) +{ + struct snd_soc_component *component = dai->component; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + + switch (dai->id) { + case tx_macro_aif1_cap: + case tx_macro_aif2_cap: + case tx_macro_aif3_cap: + *tx_slot = tx->active_ch_mask[dai->id]; + *tx_num = tx->active_ch_cnt[dai->id]; + break; + default: + break; + } + return 0; +} + +static int tx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream) +{ + struct snd_soc_component *component = dai->component; + struct tx_macro *tx = snd_soc_component_get_drvdata(component); + u16 decimator; + + decimator = tx->active_decimator[dai->id]; + + if (mute) + snd_soc_component_write_field(component, + cdc_txn_tx_path_ctl(decimator), + cdc_txn_pga_mute_mask, 0x1); + else + snd_soc_component_update_bits(component, + cdc_txn_tx_path_ctl(decimator), + cdc_txn_pga_mute_mask, 0x0); + + return 0; +} + +static struct snd_soc_dai_ops tx_macro_dai_ops = { + .hw_params = tx_macro_hw_params, + .get_channel_map = tx_macro_get_channel_map, + .mute_stream = tx_macro_digital_mute, +}; + +static struct snd_soc_dai_driver tx_macro_dai[] = { + { + .name = "tx_macro_tx1", + .id = tx_macro_aif1_cap, + .capture = { + .stream_name = "tx_aif1 capture", + .rates = tx_macro_rates, + .formats = tx_macro_formats, + .rate_max = 192000, + .rate_min = 8000, + .channels_min = 1, + .channels_max = 8, + }, + .ops = &tx_macro_dai_ops, + }, + { + .name = "tx_macro_tx2", + .id = tx_macro_aif2_cap, + .capture = { + .stream_name = "tx_aif2 capture", + .rates = tx_macro_rates, + .formats = tx_macro_formats, + .rate_max = 192000, + .rate_min = 8000, + .channels_min = 1, + .channels_max = 8, + }, + .ops = &tx_macro_dai_ops, + }, + { + .name = "tx_macro_tx3", + .id = tx_macro_aif3_cap, + .capture = { + .stream_name = "tx_aif3 capture", + .rates = tx_macro_rates, + .formats = tx_macro_formats, + .rate_max = 192000, + .rate_min = 8000, + .channels_min = 1, + .channels_max = 8, + }, + .ops = &tx_macro_dai_ops, + }, +}; + +static const char * const dec_mode_mux_text[] = { + "adc_default", "adc_low_pwr", "adc_high_perf", +}; + +static const struct soc_enum dec_mode_mux_enum[] = { + soc_enum_single(snd_soc_nopm, 0, array_size(dec_mode_mux_text), + dec_mode_mux_text), + soc_enum_single(snd_soc_nopm, 1, array_size(dec_mode_mux_text), + dec_mode_mux_text), + soc_enum_single(snd_soc_nopm, 2, array_size(dec_mode_mux_text), + dec_mode_mux_text), + soc_enum_single(snd_soc_nopm, 3, array_size(dec_mode_mux_text), + dec_mode_mux_text), + soc_enum_single(snd_soc_nopm, 4, array_size(dec_mode_mux_text), + dec_mode_mux_text), + soc_enum_single(snd_soc_nopm, 5, array_size(dec_mode_mux_text), + dec_mode_mux_text), + soc_enum_single(snd_soc_nopm, 6, array_size(dec_mode_mux_text), + dec_mode_mux_text), + soc_enum_single(snd_soc_nopm, 7, array_size(dec_mode_mux_text), + dec_mode_mux_text), +}; + +static const struct snd_kcontrol_new tx_macro_snd_controls[] = { + soc_single_s8_tlv("tx_dec0 volume", + cdc_tx0_tx_vol_ctl, + -84, 40, digital_gain), + soc_single_s8_tlv("tx_dec1 volume", + cdc_tx1_tx_vol_ctl, + -84, 40, digital_gain), + soc_single_s8_tlv("tx_dec2 volume", + cdc_tx2_tx_vol_ctl, + -84, 40, digital_gain), + soc_single_s8_tlv("tx_dec3 volume", + cdc_tx3_tx_vol_ctl, + -84, 40, digital_gain), + soc_single_s8_tlv("tx_dec4 volume", + cdc_tx4_tx_vol_ctl, + -84, 40, digital_gain), + soc_single_s8_tlv("tx_dec5 volume", + cdc_tx5_tx_vol_ctl, + -84, 40, digital_gain), + soc_single_s8_tlv("tx_dec6 volume", + cdc_tx6_tx_vol_ctl, + -84, 40, digital_gain), + soc_single_s8_tlv("tx_dec7 volume", + cdc_tx7_tx_vol_ctl, + -84, 40, digital_gain), + + soc_enum_ext("dec0 mode", dec_mode_mux_enum[0], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_enum_ext("dec1 mode", dec_mode_mux_enum[1], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_enum_ext("dec2 mode", dec_mode_mux_enum[2], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_enum_ext("dec3 mode", dec_mode_mux_enum[3], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_enum_ext("dec4 mode", dec_mode_mux_enum[4], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_enum_ext("dec5 mode", dec_mode_mux_enum[5], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_enum_ext("dec6 mode", dec_mode_mux_enum[6], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_enum_ext("dec7 mode", dec_mode_mux_enum[7], + tx_macro_dec_mode_get, tx_macro_dec_mode_put), + + soc_single_ext("dec0_bcs switch", snd_soc_nopm, 0, 1, 0, + tx_macro_get_bcs, tx_macro_set_bcs), +}; + +static int tx_macro_component_probe(struct snd_soc_component *comp) +{ + struct tx_macro *tx = snd_soc_component_get_drvdata(comp); + int i; + + snd_soc_component_init_regmap(comp, tx->regmap); + + for (i = 0; i < num_decimators; i++) { + tx->tx_hpf_work[i].tx = tx; + tx->tx_hpf_work[i].decimator = i; + init_delayed_work(&tx->tx_hpf_work[i].dwork, + tx_macro_tx_hpf_corner_freq_callback); + } + + for (i = 0; i < num_decimators; i++) { + tx->tx_mute_dwork[i].tx = tx; + tx->tx_mute_dwork[i].decimator = i; + init_delayed_work(&tx->tx_mute_dwork[i].dwork, + tx_macro_mute_update_callback); + } + tx->component = comp; + + snd_soc_component_update_bits(comp, cdc_tx0_tx_path_sec7, 0x3f, + 0x0a); + + return 0; +} + +static int swclk_gate_enable(struct clk_hw *hw) +{ + struct tx_macro *tx = to_tx_macro(hw); + struct regmap *regmap = tx->regmap; + + tx_macro_mclk_enable(tx, true); + if (tx->reset_swr) + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_swr_control, + cdc_tx_swr_reset_mask, + cdc_tx_swr_reset_enable); + + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_swr_control, + cdc_tx_swr_clk_en_mask, + cdc_tx_swr_clk_enable); + if (tx->reset_swr) + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_swr_control, + cdc_tx_swr_reset_mask, 0x0); + tx->reset_swr = false; + + return 0; +} + +static void swclk_gate_disable(struct clk_hw *hw) +{ + struct tx_macro *tx = to_tx_macro(hw); + struct regmap *regmap = tx->regmap; + + regmap_update_bits(regmap, cdc_tx_clk_rst_ctrl_swr_control, + cdc_tx_swr_clk_en_mask, 0x0); + + tx_macro_mclk_enable(tx, false); +} + +static int swclk_gate_is_enabled(struct clk_hw *hw) +{ + struct tx_macro *tx = to_tx_macro(hw); + int ret, val; + + regmap_read(tx->regmap, cdc_tx_clk_rst_ctrl_swr_control, &val); + ret = val & bit(0); + + return ret; +} + +static unsigned long swclk_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + return parent_rate / 2; +} + +static const struct clk_ops swclk_gate_ops = { + .prepare = swclk_gate_enable, + .unprepare = swclk_gate_disable, + .is_enabled = swclk_gate_is_enabled, + .recalc_rate = swclk_recalc_rate, + +}; + +static struct clk *tx_macro_register_mclk_output(struct tx_macro *tx) +{ + struct device *dev = tx->dev; + struct device_node *np = dev->of_node; + const char *parent_clk_name = null; + const char *clk_name = "lpass-tx-mclk"; + struct clk_hw *hw; + struct clk_init_data init; + int ret; + + parent_clk_name = __clk_get_name(tx->clks[2].clk); + + init.name = clk_name; + init.ops = &swclk_gate_ops; + init.flags = 0; + init.parent_names = &parent_clk_name; + init.num_parents = 1; + tx->hw.init = &init; + hw = &tx->hw; + ret = clk_hw_register(tx->dev, hw); + if (ret) + return err_ptr(ret); + + of_clk_add_provider(np, of_clk_src_simple_get, hw->clk); + + return null; +} + +static const struct snd_soc_component_driver tx_macro_component_drv = { + .name = "rx-macro", + .probe = tx_macro_component_probe, + .controls = tx_macro_snd_controls, + .num_controls = array_size(tx_macro_snd_controls), +}; + +static int tx_macro_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct tx_macro *tx; + void __iomem *base; + int ret; + + tx = devm_kzalloc(dev, sizeof(*tx), gfp_kernel); + if (!tx) + return -enomem; + + tx->clks[0].id = "macro"; + tx->clks[1].id = "dcodec"; + tx->clks[2].id = "mclk"; + tx->clks[3].id = "npl"; + tx->clks[4].id = "fsgen"; + + ret = devm_clk_bulk_get(dev, tx_num_clks_max, tx->clks); + if (ret) { + dev_err(dev, "error getting rx clocks (%d) ", ret); + return ret; + } + + base = devm_platform_ioremap_resource(pdev, 0); + if (is_err(base)) + return ptr_err(base); + + tx->regmap = devm_regmap_init_mmio(dev, base, &tx_regmap_config); + + dev_set_drvdata(dev, tx); + + tx->reset_swr = true; + tx->dev = dev; + + /* set mclk and npl rates */ + clk_set_rate(tx->clks[2].clk, mclk_freq); + clk_set_rate(tx->clks[3].clk, mclk_freq); + + ret = clk_bulk_prepare_enable(tx_num_clks_max, tx->clks); + if (ret) + return ret; + + tx_macro_register_mclk_output(tx); + + ret = devm_snd_soc_register_component(dev, &tx_macro_component_drv, + tx_macro_dai, + array_size(tx_macro_dai)); + if (ret) + goto err; + return ret; +err: + clk_bulk_disable_unprepare(tx_num_clks_max, tx->clks); + + return ret; +} + +static int tx_macro_remove(struct platform_device *pdev) +{ + struct tx_macro *tx = dev_get_drvdata(&pdev->dev); + + of_clk_del_provider(pdev->dev.of_node); + + clk_bulk_disable_unprepare(tx_num_clks_max, tx->clks); + + return 0; +} + +static const struct of_device_id tx_macro_dt_match[] = { + { .compatible = "qcom,sm8250-lpass-tx-macro" }, + { } +}; +static struct platform_driver tx_macro_driver = { + .driver = { + .name = "tx_macro", + .of_match_table = tx_macro_dt_match, + .suppress_bind_attrs = true, + }, + .probe = tx_macro_probe, + .remove = tx_macro_remove, +}; + +module_platform_driver(tx_macro_driver); + +module_description("tx macro driver"); +module_license("gpl");
Audio
c39667ddcfc516fee084e449179d54430a558298
srinivas kandagatla
sound
soc
codecs
asoc: cpcap: implement set_tdm_slot for voice call support
asoc: cpcap: implement set_tdm_slot for voice call support
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
implement set_tdm_slot for voice call support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'cpcap']
['c']
1
125
2
--- diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c +/* register 512 cpcap_reg_vaudioc --- audio regulator and bias voltage */ +#define cpcap_bit_audio_low_pwr 6 +#define cpcap_bit_aud_lowpwr_speed 5 +#define cpcap_bit_vaudiopristby 4 +#define cpcap_bit_vaudio_mode1 2 +#define cpcap_bit_vaudio_mode0 1 +#define cpcap_bit_v_audio_en 0 + + { cpcap_reg_vaudioc, 0x003f, 0x0000 }, -static int cpcap_voice_set_mute(struct snd_soc_dai *dai, - int mute, int direction) + +/* + * configure codec for voice call if requested. + * + * we can configure most with snd_soc_dai_set_sysclk(), snd_soc_dai_set_fmt() + * and snd_soc_dai_set_tdm_slot(). this function configures the rest of the + * cpcap related hardware as cpu is not involved in the voice call. + */ +static int cpcap_voice_call(struct cpcap_audio *cpcap, struct snd_soc_dai *dai, + bool voice_call) +{ + int mask, err; + + /* modem to codec vaudio_mode1 */ + mask = bit(cpcap_bit_vaudio_mode1); + err = regmap_update_bits(cpcap->regmap, cpcap_reg_vaudioc, + mask, voice_call ? mask : 0); + if (err) + return err; + + /* clear mic1_mux for call */ + mask = bit(cpcap_bit_mic1_mux); + err = regmap_update_bits(cpcap->regmap, cpcap_reg_txi, + mask, voice_call ? 0 : mask); + if (err) + return err; + + /* set mic2_mux for call */ + mask = bit(cpcap_bit_mb_on1l) | bit(cpcap_bit_mb_on1r) | + bit(cpcap_bit_mic2_mux) | bit(cpcap_bit_mic2_pga_en); + err = regmap_update_bits(cpcap->regmap, cpcap_reg_txi, + mask, voice_call ? mask : 0); + if (err) + return err; + + /* enable ldsp for call */ + mask = bit(cpcap_bit_a2_ldsp_l_en) | bit(cpcap_bit_a2_ldsp_r_en); + err = regmap_update_bits(cpcap->regmap, cpcap_reg_rxoa, + mask, voice_call ? mask : 0); + if (err) + return err; + + /* enable cpcap_bit_pga_cdc_en for call */ + mask = bit(cpcap_bit_pga_cdc_en); + err = regmap_update_bits(cpcap->regmap, cpcap_reg_rxcoa, + mask, voice_call ? mask : 0); + if (err) + return err; + + /* unmute voice for call */ + if (dai) { + err = snd_soc_dai_digital_mute(dai, !voice_call, + sndrv_pcm_stream_playback); + if (err) + return err; + } + + /* set modem to codec mic cdc and hpf for call */ + mask = bit(cpcap_bit_mic2_cdc_en) | bit(cpcap_bit_cdc_en_rx) | + bit(cpcap_bit_audohpf_1) | bit(cpcap_bit_audohpf_0) | + bit(cpcap_bit_audihpf_1) | bit(cpcap_bit_audihpf_0); + err = regmap_update_bits(cpcap->regmap, cpcap_reg_cc, + mask, voice_call ? mask : 0); + if (err) + return err; + + /* enable modem to codec cdc for call*/ + mask = bit(cpcap_bit_cdc_clk_en); + err = regmap_update_bits(cpcap->regmap, cpcap_reg_cdi, + mask, voice_call ? mask : 0); + + return err; +} + +static int cpcap_voice_set_tdm_slot(struct snd_soc_dai *dai, + unsigned int tx_mask, unsigned int rx_mask, + int slots, int slot_width) +{ + struct snd_soc_component *component = dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); + int err, ts_mask, mask; + bool voice_call; + + /* + * primitive test for voice call, probably needs more checks + * later on for 16-bit calls detected, bluetooth headset etc. + */ + if (tx_mask == 0 && rx_mask == 1 && slot_width == 8) + voice_call = true; + else + voice_call = false; + + ts_mask = 0x7 << cpcap_bit_mic2_timeslot0; + ts_mask |= 0x7 << cpcap_bit_mic1_rx_timeslot0; + + mask = (tx_mask & 0x7) << cpcap_bit_mic2_timeslot0; + mask |= (rx_mask & 0x7) << cpcap_bit_mic1_rx_timeslot0; + + err = regmap_update_bits(cpcap->regmap, cpcap_reg_cdi, + ts_mask, mask); + if (err) + return err; + + err = cpcap_set_samprate(cpcap, cpcap_dai_voice, slot_width * 1000); + if (err) + return err; + + err = cpcap_voice_call(cpcap, dai, voice_call); + if (err) + return err; + + return 0; +} + +static int cpcap_voice_set_mute(struct snd_soc_dai *dai, int mute, int direction) + .set_tdm_slot = cpcap_voice_set_tdm_slot,
Audio
0dedbde5062dbc3cf71ab1ba40792c04a68008e9
tony lindgren
sound
soc
codecs
asoc: mediatek: mt8192-mt6359: support audio over dp
if the dts property is specified, the dp bridge should populate a "hdmi-codec" platform device (sound/soc/codecs/hdmi-codec.c).
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support audio over dp
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'mediatek', 'mt8192-mt6359']
['c']
1
37
2
- notifies dp bridge when setting hw_param. - notifies asoc when jack detection events. --- diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c + struct snd_soc_jack hdmi_jack; +static int mt8192_mt6359_hdmi_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *cmpnt_codec = + asoc_rtd_to_codec(rtd, 0)->component; + struct mt8192_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card); + int ret; + + ret = snd_soc_card_jack_new(rtd->card, "hdmi jack", snd_jack_lineout, + &priv->hdmi_jack, null, 0); + if (ret) { + dev_err(rtd->dev, "hdmi jack creation failed: %d ", ret); + return ret; + } + + return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, null); +} + - dailink_comp_array(comp_dummy()), + dailink_comp_array(comp_codec(null, "i2s-hifi")), + .dai_fmt = snd_soc_daifmt_dsp_a | + snd_soc_daifmt_ib_nf | + snd_soc_daifmt_cbm_cfm, + .be_hw_params_fixup = mt8192_i2s_hw_params_fixup, + .ignore = 1, + .init = mt8192_mt6359_hdmi_init, + snd_soc_dapm_output("tdm out"), + /* tdm */ + { "tdm out", null, "tdm" }, - struct device_node *platform_node; + struct device_node *platform_node, *hdmi_codec; + hdmi_codec = of_parse_phandle(pdev->dev.of_node, + "mediatek,hdmi-codec", 0); + + if (hdmi_codec && strcmp(dai_link->name, "tdm") == 0) { + dai_link->codecs->of_node = hdmi_codec; + dai_link->ignore = 0; + } +
Audio
0d80c48c847842de488e76ae434ccb74397623c3
tzung bi shih
sound
soc
mediatek, mt8192
asoc: stm32: i2s: add master clock provider
add master clock generation support in stm32 i2s driver. the master clock provided by i2s can be used to feed a codec.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add master clock provider
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'stm32', 'i2s']
['c']
1
266
44
--- diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c --- a/sound/soc/stm/stm32_i2s.c +++ b/sound/soc/stm/stm32_i2s.c +#include <linux/clk-provider.h> +#define stm32_i2s_name_len 32 +#define stm32_i2s_rate_11k 11025 + + * @i2smclk: master clock from i2s mclk provider + * @divider: prescaler division ratio + * @div: prescaler div field + * @odd: prescaler odd field + struct clk *i2smclk; + unsigned int divider; + unsigned int div; + bool odd; +struct stm32_i2smclk_data { + struct clk_hw hw; + unsigned long freq; + struct stm32_i2s_data *i2s_data; +}; + +#define to_mclk_data(_hw) container_of(_hw, struct stm32_i2smclk_data, hw) + +static int stm32_i2s_calc_clk_div(struct stm32_i2s_data *i2s, + unsigned long input_rate, + unsigned long output_rate) +{ + unsigned int ratio, div, divider = 1; + bool odd; + + ratio = div_round_closest(input_rate, output_rate); + + /* check the parity of the divider */ + odd = ratio & 0x1; + + /* compute the div prescaler */ + div = ratio >> 1; + + /* if div is 0 actual divider is 1 */ + if (div) { + divider = ((2 * div) + odd); + dev_dbg(&i2s->pdev->dev, "divider: 2*%d(div)+%d(odd) = %d ", + div, odd, divider); + } + + /* division by three is not allowed by i2s prescaler */ + if ((div == 1 && odd) || div > i2s_cgfr_i2sdiv_max) { + dev_err(&i2s->pdev->dev, "wrong divider setting "); + return -einval; + } + + if (input_rate % divider) + dev_dbg(&i2s->pdev->dev, + "rate not accurate. requested (%ld), actual (%ld) ", + output_rate, input_rate / divider); + + i2s->div = div; + i2s->odd = odd; + i2s->divider = divider; + + return 0; +} + +static int stm32_i2s_set_clk_div(struct stm32_i2s_data *i2s) +{ + u32 cgfr, cgfr_mask; + + cgfr = i2s_cgfr_i2sdiv_set(i2s->div) | (i2s->odd << i2s_cgfr_odd_shift); + cgfr_mask = i2s_cgfr_i2sdiv_mask | i2s_cgfr_odd; + + return regmap_update_bits(i2s->regmap, stm32_i2s_cgfr_reg, + cgfr_mask, cgfr); +} + +static int stm32_i2s_set_parent_clock(struct stm32_i2s_data *i2s, + unsigned int rate) +{ + struct platform_device *pdev = i2s->pdev; + struct clk *parent_clk; + int ret; + + if (!(rate % stm32_i2s_rate_11k)) + parent_clk = i2s->x11kclk; + else + parent_clk = i2s->x8kclk; + + ret = clk_set_parent(i2s->i2sclk, parent_clk); + if (ret) + dev_err(&pdev->dev, + "error %d setting i2sclk parent clock ", ret); + + return ret; +} + +static long stm32_i2smclk_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *prate) +{ + struct stm32_i2smclk_data *mclk = to_mclk_data(hw); + struct stm32_i2s_data *i2s = mclk->i2s_data; + int ret; + + ret = stm32_i2s_calc_clk_div(i2s, *prate, rate); + if (ret) + return ret; + + mclk->freq = *prate / i2s->divider; + + return mclk->freq; +} + +static unsigned long stm32_i2smclk_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct stm32_i2smclk_data *mclk = to_mclk_data(hw); + + return mclk->freq; +} + +static int stm32_i2smclk_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct stm32_i2smclk_data *mclk = to_mclk_data(hw); + struct stm32_i2s_data *i2s = mclk->i2s_data; + int ret; + + ret = stm32_i2s_calc_clk_div(i2s, parent_rate, rate); + if (ret) + return ret; + + ret = stm32_i2s_set_clk_div(i2s); + if (ret) + return ret; + + mclk->freq = rate; + + return 0; +} + +static int stm32_i2smclk_enable(struct clk_hw *hw) +{ + struct stm32_i2smclk_data *mclk = to_mclk_data(hw); + struct stm32_i2s_data *i2s = mclk->i2s_data; + + dev_dbg(&i2s->pdev->dev, "enable master clock "); + + return regmap_update_bits(i2s->regmap, stm32_i2s_cgfr_reg, + i2s_cgfr_mckoe, i2s_cgfr_mckoe); +} + +static void stm32_i2smclk_disable(struct clk_hw *hw) +{ + struct stm32_i2smclk_data *mclk = to_mclk_data(hw); + struct stm32_i2s_data *i2s = mclk->i2s_data; + + dev_dbg(&i2s->pdev->dev, "disable master clock "); + + regmap_update_bits(i2s->regmap, stm32_i2s_cgfr_reg, i2s_cgfr_mckoe, 0); +} + +static const struct clk_ops mclk_ops = { + .enable = stm32_i2smclk_enable, + .disable = stm32_i2smclk_disable, + .recalc_rate = stm32_i2smclk_recalc_rate, + .round_rate = stm32_i2smclk_round_rate, + .set_rate = stm32_i2smclk_set_rate, +}; + +static int stm32_i2s_add_mclk_provider(struct stm32_i2s_data *i2s) +{ + struct clk_hw *hw; + struct stm32_i2smclk_data *mclk; + struct device *dev = &i2s->pdev->dev; + const char *pname = __clk_get_name(i2s->i2sclk); + char *mclk_name, *p, *s = (char *)pname; + int ret, i = 0; + + mclk = devm_kzalloc(dev, sizeof(*mclk), gfp_kernel); + if (!mclk) + return -enomem; + + mclk_name = devm_kcalloc(dev, sizeof(char), + stm32_i2s_name_len, gfp_kernel); + if (!mclk_name) + return -enomem; + + /* + * forge mclk clock name from parent clock name and suffix. + * string after "_" char is stripped in parent name. + */ + p = mclk_name; + while (*s && *s != '_' && (i < (stm32_i2s_name_len - 7))) { + *p++ = *s++; + i++; + } + strcat(p, "_mclk"); + + mclk->hw.init = clk_hw_init(mclk_name, pname, &mclk_ops, 0); + mclk->i2s_data = i2s; + hw = &mclk->hw; + + dev_dbg(dev, "register master clock %s ", mclk_name); + ret = devm_clk_hw_register(&i2s->pdev->dev, hw); + if (ret) { + dev_err(dev, "mclk register fails with error %d ", ret); + return ret; + } + i2s->i2smclk = hw->clk; + + /* register mclk provider */ + return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw); +} + + int ret = 0; - dev_dbg(cpu_dai->dev, "i2s mclk frequency is %uhz ", freq); + dev_dbg(cpu_dai->dev, "i2s mclk frequency is %uhz. mode: %s, dir: %s ", + freq, stm32_i2s_is_master(i2s) ? "master" : "slave", + dir ? "output" : "input"); - if ((dir == snd_soc_clock_out) && stm32_i2s_is_master(i2s)) { - i2s->mclk_rate = freq; + /* mclk generation is available only in master mode */ + if (dir == snd_soc_clock_out && stm32_i2s_is_master(i2s)) { + if (!i2s->i2smclk) { + dev_dbg(cpu_dai->dev, "no mclk registered "); + return 0; + } - /* enable master clock if master mode and mclk-fs are set */ - return regmap_update_bits(i2s->regmap, stm32_i2s_cgfr_reg, - i2s_cgfr_mckoe, i2s_cgfr_mckoe); + /* assume shutdown if requested frequency is 0hz */ + if (!freq) { + /* release mclk rate only if rate was actually set */ + if (i2s->mclk_rate) { + clk_rate_exclusive_put(i2s->i2smclk); + i2s->mclk_rate = 0; + } + return regmap_update_bits(i2s->regmap, + stm32_i2s_cgfr_reg, + i2s_cgfr_mckoe, 0); + } + /* if master clock is used, set parent clock now */ + ret = stm32_i2s_set_parent_clock(i2s, freq); + if (ret) + return ret; + ret = clk_set_rate_exclusive(i2s->i2smclk, freq); + if (ret) { + dev_err(cpu_dai->dev, "could not set mclk rate "); + return ret; + } + ret = regmap_update_bits(i2s->regmap, stm32_i2s_cgfr_reg, + i2s_cgfr_mckoe, i2s_cgfr_mckoe); + if (!ret) + i2s->mclk_rate = freq; - return 0; + return ret; - unsigned int tmp, div, real_div, nb_bits, frame_len; + unsigned int nb_bits, frame_len; + u32 cgfr; - u32 cgfr, cgfr_mask; - bool odd; - tmp = div_round_closest(i2s_clock_rate, i2s->mclk_rate); + ret = stm32_i2s_calc_clk_div(i2s, i2s_clock_rate, + i2s->mclk_rate); + if (ret) + return ret; - tmp = div_round_closest(i2s_clock_rate, (nb_bits * rate)); - } - - /* check the parity of the divider */ - odd = tmp & 0x1; - - /* compute the div prescaler */ - div = tmp >> 1; - - cgfr = i2s_cgfr_i2sdiv_set(div) | (odd << i2s_cgfr_odd_shift); - cgfr_mask = i2s_cgfr_i2sdiv_mask | i2s_cgfr_odd; - - real_div = ((2 * div) + odd); - dev_dbg(cpu_dai->dev, "i2s clk: %ld, sclk: %d ", - i2s_clock_rate, rate); - dev_dbg(cpu_dai->dev, "divider: 2*%d(div)+%d(odd) = %d ", - div, odd, real_div); - - if (((div == 1) && odd) || (div > i2s_cgfr_i2sdiv_max)) { - dev_err(cpu_dai->dev, "wrong divider setting "); - return -einval; + ret = stm32_i2s_calc_clk_div(i2s, i2s_clock_rate, + (nb_bits * rate)); + if (ret) + return ret; - if (!div && !odd) - dev_warn(cpu_dai->dev, "real divider forced to 1 "); - - ret = regmap_update_bits(i2s->regmap, stm32_i2s_cgfr_reg, - cgfr_mask, cgfr); + ret = stm32_i2s_set_clk_div(i2s); - regmap_update_bits(i2s->regmap, stm32_i2s_cgfr_reg, - i2s_cgfr_mckoe, (unsigned int)~i2s_cgfr_mckoe); - + /* register mclk provider if requested */ + if (of_find_property(np, "#clock-cells", null)) { + ret = stm32_i2s_add_mclk_provider(i2s); + if (ret < 0) + return ret; + } + - ret = stm32_i2s_parse_dt(pdev, i2s); - if (ret) - return ret; - + ret = stm32_i2s_parse_dt(pdev, i2s); + if (ret) + return ret; +
Audio
8a262e614ef8675cfde924c6ddf873a95db0be6a
olivier moysan
sound
soc
stm
asoc: tegra: add audio graph based card driver
add tegra audio machine driver which is based on generic audio graph card driver. it re-uses most of the common stuff from audio graph driver and uses the same dt binding. required tegra specific customizations are done in the driver and additional dt bindings are required for clock handling.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add audio graph based card driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'tegra']
['kconfig', 'c', 'makefile']
3
262
0
- update pll rates at runtime: tegra hw supports multiple sample rates - internal structure 'tegra_audio_graph_data' is used to maintain clock - the 'force_dpcm' flag is set to use dpcm for all dai links. - the 'component_chaining' flag is set to use dpcm with component model. --- diff --git a/sound/soc/tegra/kconfig b/sound/soc/tegra/kconfig --- a/sound/soc/tegra/kconfig +++ b/sound/soc/tegra/kconfig +config snd_soc_tegra_audio_graph_card + tristate "audio graph card based tegra driver" + depends on snd_audio_graph_card + help + config to enable tegra audio machine driver based on generic + audio graph driver. it is a thin driver written to customize + few things for tegra audio. most of the code is re-used from + audio graph driver and the same dt bindings are used. + diff --git a/sound/soc/tegra/makefile b/sound/soc/tegra/makefile --- a/sound/soc/tegra/makefile +++ b/sound/soc/tegra/makefile +snd-soc-tegra-audio-graph-card-objs := tegra_audio_graph_card.o +obj-$(config_snd_soc_tegra_audio_graph_card) += snd-soc-tegra-audio-graph-card.o diff --git a/sound/soc/tegra/tegra_audio_graph_card.c b/sound/soc/tegra/tegra_audio_graph_card.c --- /dev/null +++ b/sound/soc/tegra/tegra_audio_graph_card.c +// spdx-license-identifier: gpl-2.0-only +// +// tegra_audio_graph_card.c - audio graph based tegra machine driver +// +// copyright (c) 2020 nvidia corporation. all rights reserved. + +#include <linux/math64.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <sound/graph_card.h> +#include <sound/pcm_params.h> + +#define max_plla_out0_div 128 + +#define simple_to_tegra_priv(simple) \ + container_of(simple, struct tegra_audio_priv, simple) + +enum srate_type { + /* + * sample rates multiple of 8000 hz and below are supported: + * ( 8000, 16000, 32000, 48000, 96000, 192000 hz ) + */ + x8_rate, + + /* + * sample rates multiple of 11025 hz and below are supported: + * ( 11025, 22050, 44100, 88200, 176400 hz ) + */ + x11_rate, + + num_rate_type, +}; + +struct tegra_audio_priv { + struct asoc_simple_priv simple; + struct clk *clk_plla_out0; + struct clk *clk_plla; +}; + +/* tegra audio chip data */ +struct tegra_audio_cdata { + unsigned int plla_rates[num_rate_type]; + unsigned int plla_out0_rates[num_rate_type]; +}; + +/* setup pll clock as per the given sample rate */ +static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(rtd->card); + struct tegra_audio_priv *priv = simple_to_tegra_priv(simple); + struct device *dev = rtd->card->dev; + const struct tegra_audio_cdata *data = of_device_get_match_data(dev); + unsigned int plla_rate, plla_out0_rate, bclk; + unsigned int srate = params_rate(params); + int err; + + switch (srate) { + case 11025: + case 22050: + case 44100: + case 88200: + case 176400: + plla_out0_rate = data->plla_out0_rates[x11_rate]; + plla_rate = data->plla_rates[x11_rate]; + break; + case 8000: + case 16000: + case 32000: + case 48000: + case 96000: + case 192000: + plla_out0_rate = data->plla_out0_rates[x8_rate]; + plla_rate = data->plla_rates[x8_rate]; + break; + default: + dev_err(rtd->card->dev, "unsupported sample rate %u ", + srate); + return -einval; + } + + /* + * below is the clock relation: + * + * plla + * | + * |--> plla_out0 + * | + * |---> i2s modules + * | + * |---> dmic modules + * | + * |---> dspk modules + * + * + * default plla_out0 rate might be too high when i/o is running + * at minimum pcm configurations. this may result in incorrect + * clock rates and glitchy audio. the maximum divider is 128 + * and any thing higher than that won't work. thus reduce plla_out0 + * to work for lower configurations. + * + * this problem is seen for i2s only, as dmic and dspk minimum + * clock requirements are under allowed divider limits. + */ + bclk = srate * params_channels(params) * params_width(params); + if (div_u64(plla_out0_rate, bclk) > max_plla_out0_div) + plla_out0_rate >>= 1; + + dev_dbg(rtd->card->dev, + "update clock rates: plla(= %u hz) and plla_out0(= %u hz) ", + plla_rate, plla_out0_rate); + + /* set plla rate */ + err = clk_set_rate(priv->clk_plla, plla_rate); + if (err) { + dev_err(rtd->card->dev, + "can't set plla rate for %u, err: %d ", + plla_rate, err); + return err; + } + + /* set plla_out0 rate */ + err = clk_set_rate(priv->clk_plla_out0, plla_out0_rate); + if (err) { + dev_err(rtd->card->dev, + "can't set plla_out0 rate %u, err: %d ", + plla_out0_rate, err); + return err; + } + + return err; +} + +static int tegra_audio_graph_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); + int err; + + /* + * this gets called for each dai link (fe or be) when dpcm is used. + * we may not want to update plla rate for each call. so plla update + * must be restricted to external i/o links (i2s, dmic or dspk) since + * they actually depend on it. i/o modules update their clocks in + * hw_param() of their respective component driver and plla rate + * update here helps them to derive appropriate rates. + * + * todo: when more hw accelerators get added (like sample rate + * converter, volume gain controller etc., which don't really + * depend on plla) we need a better way to filter here. + */ + if (cpu_dai->driver->ops && rtd->dai_link->no_pcm) { + err = tegra_audio_graph_update_pll(substream, params); + if (err) + return err; + } + + return asoc_simple_hw_params(substream, params); +} + +static const struct snd_soc_ops tegra_audio_graph_ops = { + .startup = asoc_simple_startup, + .shutdown = asoc_simple_shutdown, + .hw_params = tegra_audio_graph_hw_params, +}; + +static int tegra_audio_graph_card_probe(struct snd_soc_card *card) +{ + struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(card); + struct tegra_audio_priv *priv = simple_to_tegra_priv(simple); + + priv->clk_plla = devm_clk_get(card->dev, "pll_a"); + if (is_err(priv->clk_plla)) { + dev_err(card->dev, "can't retrieve clk pll_a "); + return ptr_err(priv->clk_plla); + } + + priv->clk_plla_out0 = devm_clk_get(card->dev, "plla_out0"); + if (is_err(priv->clk_plla_out0)) { + dev_err(card->dev, "can't retrieve clk plla_out0 "); + return ptr_err(priv->clk_plla_out0); + } + + return graph_card_probe(card); +} + +static int tegra_audio_graph_probe(struct platform_device *pdev) +{ + struct tegra_audio_priv *priv; + struct device *dev = &pdev->dev; + struct snd_soc_card *card; + + priv = devm_kzalloc(dev, sizeof(*priv), gfp_kernel); + if (!priv) + return -enomem; + + card = simple_priv_to_card(&priv->simple); + + card->probe = tegra_audio_graph_card_probe; + + /* graph_parse_of() depends on below */ + card->component_chaining = 1; + priv->simple.ops = &tegra_audio_graph_ops; + priv->simple.force_dpcm = 1; + + return graph_parse_of(&priv->simple, dev); +} + +static const struct tegra_audio_cdata tegra210_data = { + /* plla */ + .plla_rates[x8_rate] = 368640000, + .plla_rates[x11_rate] = 338688000, + /* plla_out0 */ + .plla_out0_rates[x8_rate] = 49152000, + .plla_out0_rates[x11_rate] = 45158400, +}; + +static const struct tegra_audio_cdata tegra186_data = { + /* plla */ + .plla_rates[x8_rate] = 245760000, + .plla_rates[x11_rate] = 270950400, + /* plla_out0 */ + .plla_out0_rates[x8_rate] = 49152000, + .plla_out0_rates[x11_rate] = 45158400, +}; + +static const struct of_device_id graph_of_tegra_match[] = { + { .compatible = "nvidia,tegra210-audio-graph-card", + .data = &tegra210_data }, + { .compatible = "nvidia,tegra186-audio-graph-card", + .data = &tegra186_data }, + {}, +}; +module_device_table(of, graph_of_tegra_match); + +static struct platform_driver tegra_audio_graph_card = { + .driver = { + .name = "tegra-audio-graph-card", + .pm = &snd_soc_pm_ops, + .of_match_table = graph_of_tegra_match, + }, + .probe = tegra_audio_graph_probe, +}; +module_platform_driver(tegra_audio_graph_card); + +module_license("gpl v2"); +module_description("asoc tegra audio graph sound card"); +module_author("sameer pujar <spujar@nvidia.com>");
Audio
202e2f7745437aa5b694de92cbd30bb43b23fbed
sameer pujar
sound
soc
tegra
asoc: txx9: remove driver
cpu support for tx49xx is getting removed, so remove sound support for it.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
remove driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ', 'txx9']
['h', 'kconfig', 'c', 'makefile']
8
0
855
--- diff --git a/sound/soc/kconfig b/sound/soc/kconfig --- a/sound/soc/kconfig +++ b/sound/soc/kconfig -source "sound/soc/txx9/kconfig" diff --git a/sound/soc/makefile b/sound/soc/makefile --- a/sound/soc/makefile +++ b/sound/soc/makefile -obj-$(config_snd_soc) += txx9/ diff --git a/sound/soc/txx9/kconfig b/sound/soc/txx9/kconfig --- a/sound/soc/txx9/kconfig +++ /dev/null -# spdx-license-identifier: gpl-2.0-only -## -## txx9 aclc -## -config snd_soc_txx9aclc - tristate "soc audio for txx9" - depends on has_txx9_aclc && txx9_dmac - help - this option enables support for the ac link controllers in txx9 soc. - -config has_txx9_aclc - bool - -config snd_soc_txx9aclc_ac97 - tristate - select ac97_bus - select snd_ac97_codec - select snd_soc_ac97_bus - - -## -## boards -## -config snd_soc_txx9aclc_generic - tristate "generic txx9 aclc sound machine" - depends on snd_soc_txx9aclc - select snd_soc_txx9aclc_ac97 - select snd_soc_ac97_codec - help - this is a generic ac97 sound machine for use in txx9 based systems. diff --git a/sound/soc/txx9/makefile b/sound/soc/txx9/makefile --- a/sound/soc/txx9/makefile +++ /dev/null -# spdx-license-identifier: gpl-2.0 -# platform -snd-soc-txx9aclc-objs := txx9aclc.o -snd-soc-txx9aclc-ac97-objs := txx9aclc-ac97.o - -obj-$(config_snd_soc_txx9aclc) += snd-soc-txx9aclc.o -obj-$(config_snd_soc_txx9aclc_ac97) += snd-soc-txx9aclc-ac97.o - -# machine -snd-soc-txx9aclc-generic-objs := txx9aclc-generic.o - -obj-$(config_snd_soc_txx9aclc_generic) += snd-soc-txx9aclc-generic.o diff --git a/sound/soc/txx9/txx9aclc-ac97.c b/sound/soc/txx9/txx9aclc-ac97.c --- a/sound/soc/txx9/txx9aclc-ac97.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-only -/* - * txx9 aclc ac97 driver - * - * copyright (c) 2009 atsushi nemoto - * - * based on rbtx49xx patch from celf patch archive. - * (c) copyright toshiba corporation 2004-2006 - */ - -#include <linux/init.h> -#include <linux/module.h> -#include <linux/delay.h> -#include <linux/interrupt.h> -#include <linux/io.h> -#include <linux/gfp.h> -#include <asm/mach-tx39xx/ioremap.h> /* for txx9_directmap_base */ -#include <sound/core.h> -#include <sound/pcm.h> -#include <sound/soc.h> -#include "txx9aclc.h" - -#define ac97_dir \ - (snd_soc_daidir_playback | snd_soc_daidir_capture) - -#define ac97_rates \ - sndrv_pcm_rate_8000_48000 - -#ifdef __big_endian -#define ac97_fmts sndrv_pcm_fmtbit_s16_be -#else -#define ac97_fmts sndrv_pcm_fmtbit_s16_le -#endif - -static declare_wait_queue_head(ac97_waitq); - -/* revisit: how to find txx9aclc_drvdata from snd_ac97? */ -static struct txx9aclc_plat_drvdata *txx9aclc_drvdata; - -static int txx9aclc_regready(struct txx9aclc_plat_drvdata *drvdata) -{ - return __raw_readl(drvdata->base + acintsts) & acint_regaccrdy; -} - -/* ac97 controller reads codec register */ -static unsigned short txx9aclc_ac97_read(struct snd_ac97 *ac97, - unsigned short reg) -{ - struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; - void __iomem *base = drvdata->base; - u32 dat; - - if (!(__raw_readl(base + acintsts) & acint_codecrdy(ac97->num))) - return 0xffff; - reg |= ac97->num << 7; - dat = (reg << acregacc_reg_shift) | acregacc_read; - __raw_writel(dat, base + acregacc); - __raw_writel(acint_regaccrdy, base + acinten); - if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(txx9aclc_drvdata), hz)) { - __raw_writel(acint_regaccrdy, base + acintdis); - printk(kern_err "ac97 read timeout (reg %#x) ", reg); - dat = 0xffff; - goto done; - } - dat = __raw_readl(base + acregacc); - if (((dat >> acregacc_reg_shift) & 0xff) != reg) { - printk(kern_err "reg mismatch %x with %x ", - dat, reg); - dat = 0xffff; - goto done; - } - dat = (dat >> acregacc_dat_shift) & 0xffff; -done: - __raw_writel(acint_regaccrdy, base + acintdis); - return dat; -} - -/* ac97 controller writes to codec register */ -static void txx9aclc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, - unsigned short val) -{ - struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; - void __iomem *base = drvdata->base; - - __raw_writel(((reg | (ac97->num << 7)) << acregacc_reg_shift) | - (val << acregacc_dat_shift), - base + acregacc); - __raw_writel(acint_regaccrdy, base + acinten); - if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(txx9aclc_drvdata), hz)) { - printk(kern_err - "ac97 write timeout (reg %#x) ", reg); - } - __raw_writel(acint_regaccrdy, base + acintdis); -} - -static void txx9aclc_ac97_cold_reset(struct snd_ac97 *ac97) -{ - struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; - void __iomem *base = drvdata->base; - u32 ready = acint_codecrdy(ac97->num) | acint_regaccrdy; - - __raw_writel(acctl_enlink, base + acctldis); - udelay(1); - __raw_writel(acctl_enlink, base + acctlen); - /* wait for primary codec ready status */ - __raw_writel(ready, base + acinten); - if (!wait_event_timeout(ac97_waitq, - (__raw_readl(base + acintsts) & ready) == ready, - hz)) { - dev_err(&ac97->dev, "primary codec is not ready " - "(status %#x) ", - __raw_readl(base + acintsts)); - } - __raw_writel(acint_regaccrdy, base + acintsts); - __raw_writel(ready, base + acintdis); -} - -/* ac97 controller operations */ -static struct snd_ac97_bus_ops txx9aclc_ac97_ops = { - .read = txx9aclc_ac97_read, - .write = txx9aclc_ac97_write, - .reset = txx9aclc_ac97_cold_reset, -}; - -static irqreturn_t txx9aclc_ac97_irq(int irq, void *dev_id) -{ - struct txx9aclc_plat_drvdata *drvdata = dev_id; - void __iomem *base = drvdata->base; - - __raw_writel(__raw_readl(base + acintmsts), base + acintdis); - wake_up(&ac97_waitq); - return irq_handled; -} - -static int txx9aclc_ac97_probe(struct snd_soc_dai *dai) -{ - txx9aclc_drvdata = snd_soc_dai_get_drvdata(dai); - return 0; -} - -static int txx9aclc_ac97_remove(struct snd_soc_dai *dai) -{ - struct txx9aclc_plat_drvdata *drvdata = snd_soc_dai_get_drvdata(dai); - - /* disable ac-link */ - __raw_writel(acctl_enlink, drvdata->base + acctldis); - txx9aclc_drvdata = null; - return 0; -} - -static struct snd_soc_dai_driver txx9aclc_ac97_dai = { - .probe = txx9aclc_ac97_probe, - .remove = txx9aclc_ac97_remove, - .playback = { - .rates = ac97_rates, - .formats = ac97_fmts, - .channels_min = 2, - .channels_max = 2, - }, - .capture = { - .rates = ac97_rates, - .formats = ac97_fmts, - .channels_min = 2, - .channels_max = 2, - }, -}; - -static const struct snd_soc_component_driver txx9aclc_ac97_component = { - .name = "txx9aclc-ac97", -}; - -static int txx9aclc_ac97_dev_probe(struct platform_device *pdev) -{ - struct txx9aclc_plat_drvdata *drvdata; - struct resource *r; - int err; - int irq; - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), gfp_kernel); - if (!drvdata) - return -enomem; - - r = platform_get_resource(pdev, ioresource_mem, 0); - drvdata->base = devm_ioremap_resource(&pdev->dev, r); - if (is_err(drvdata->base)) - return ptr_err(drvdata->base); - - platform_set_drvdata(pdev, drvdata); - drvdata->physbase = r->start; - if (sizeof(drvdata->physbase) > sizeof(r->start) && - r->start >= txx9_directmap_base && - r->start < txx9_directmap_base + 0x400000) - drvdata->physbase |= 0xf00000000ull; - err = devm_request_irq(&pdev->dev, irq, txx9aclc_ac97_irq, - 0, dev_name(&pdev->dev), drvdata); - if (err < 0) - return err; - - err = snd_soc_set_ac97_ops(&txx9aclc_ac97_ops); - if (err < 0) - return err; - - return devm_snd_soc_register_component(&pdev->dev, &txx9aclc_ac97_component, - &txx9aclc_ac97_dai, 1); -} - -static int txx9aclc_ac97_dev_remove(struct platform_device *pdev) -{ - snd_soc_set_ac97_ops(null); - return 0; -} - -static struct platform_driver txx9aclc_ac97_driver = { - .probe = txx9aclc_ac97_dev_probe, - .remove = txx9aclc_ac97_dev_remove, - .driver = { - .name = "txx9aclc-ac97", - }, -}; - -module_platform_driver(txx9aclc_ac97_driver); - -module_author("atsushi nemoto <anemo@mba.ocn.ne.jp>"); -module_description("txx9 aclc ac97 driver"); -module_license("gpl"); -module_alias("platform:txx9aclc-ac97"); diff --git a/sound/soc/txx9/txx9aclc-generic.c b/sound/soc/txx9/txx9aclc-generic.c --- a/sound/soc/txx9/txx9aclc-generic.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-only -/* - * generic txx9 aclc machine driver - * - * copyright (c) 2009 atsushi nemoto - * - * based on rbtx49xx patch from celf patch archive. - * (c) copyright toshiba corporation 2004-2006 - * - * this is a very generic ac97 sound machine driver for boards which - * have (ac97) audio at aclc (e.g. rbtx49xx boards). - */ - -#include <linux/module.h> -#include <linux/platform_device.h> -#include <sound/core.h> -#include <sound/pcm.h> -#include <sound/soc.h> -#include "txx9aclc.h" - -snd_soc_dailink_defs(hifi, - dailink_comp_array(comp_cpu("txx9aclc-ac97")), - dailink_comp_array(comp_codec("ac97-codec", "ac97-hifi")), - dailink_comp_array(comp_platform("txx9aclc-pcm-audio"))); - -static struct snd_soc_dai_link txx9aclc_generic_dai = { - .name = "ac97", - .stream_name = "ac97 hifi", - snd_soc_dailink_reg(hifi), -}; - -static struct snd_soc_card txx9aclc_generic_card = { - .name = "generic txx9 aclc audio", - .owner = this_module, - .dai_link = &txx9aclc_generic_dai, - .num_links = 1, -}; - -static struct platform_device *soc_pdev; - -static int __init txx9aclc_generic_probe(struct platform_device *pdev) -{ - int ret; - - soc_pdev = platform_device_alloc("soc-audio", -1); - if (!soc_pdev) - return -enomem; - platform_set_drvdata(soc_pdev, &txx9aclc_generic_card); - ret = platform_device_add(soc_pdev); - if (ret) { - platform_device_put(soc_pdev); - return ret; - } - - return 0; -} - -static int __exit txx9aclc_generic_remove(struct platform_device *pdev) -{ - platform_device_unregister(soc_pdev); - return 0; -} - -static struct platform_driver txx9aclc_generic_driver = { - .remove = __exit_p(txx9aclc_generic_remove), - .driver = { - .name = "txx9aclc-generic", - }, -}; - -static int __init txx9aclc_generic_init(void) -{ - return platform_driver_probe(&txx9aclc_generic_driver, - txx9aclc_generic_probe); -} - -static void __exit txx9aclc_generic_exit(void) -{ - platform_driver_unregister(&txx9aclc_generic_driver); -} - -module_init(txx9aclc_generic_init); -module_exit(txx9aclc_generic_exit); - -module_author("atsushi nemoto <anemo@mba.ocn.ne.jp>"); -module_description("generic txx9 aclc alsa soc audio driver"); -module_license("gpl"); -module_alias("platform:txx9aclc-generic"); diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c --- a/sound/soc/txx9/txx9aclc.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-only -/* - * generic txx9 aclc platform driver - * - * copyright (c) 2009 atsushi nemoto - * - * based on rbtx49xx patch from celf patch archive. - * (c) copyright toshiba corporation 2004-2006 - */ - -#include <linux/module.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/scatterlist.h> -#include <linux/slab.h> -#include <linux/dmaengine.h> -#include <sound/core.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> -#include <sound/soc.h> -#include "txx9aclc.h" - -#define drv_name "txx9aclc" - -static struct txx9aclc_soc_device { - struct txx9aclc_dmadata dmadata[2]; -} txx9aclc_soc_device; - -/* revisit: how to find txx9aclc_drvdata from snd_ac97? */ -static struct txx9aclc_plat_drvdata *txx9aclc_drvdata; - -static int txx9aclc_dma_init(struct txx9aclc_soc_device *dev, - struct txx9aclc_dmadata *dmadata); - -static const struct snd_pcm_hardware txx9aclc_pcm_hardware = { - /* - * revisit: sndrv_pcm_info_mmap | sndrv_pcm_info_mmap_valid - * needs more works for noncoherent mips. - */ - .info = sndrv_pcm_info_interleaved | - sndrv_pcm_info_batch | - sndrv_pcm_info_pause, - .period_bytes_min = 1024, - .period_bytes_max = 8 * 1024, - .periods_min = 2, - .periods_max = 4096, - .buffer_bytes_max = 32 * 1024, -}; - -static int txx9aclc_pcm_hw_params(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct txx9aclc_dmadata *dmadata = runtime->private_data; - - dev_dbg(component->dev, - "runtime->dma_area = %#lx dma_addr = %#lx dma_bytes = %zd " - "runtime->min_align %ld ", - (unsigned long)runtime->dma_area, - (unsigned long)runtime->dma_addr, runtime->dma_bytes, - runtime->min_align); - dev_dbg(component->dev, - "periods %d period_bytes %d stream %d ", - params_periods(params), params_period_bytes(params), - substream->stream); - - dmadata->substream = substream; - dmadata->pos = 0; - return 0; -} - -static int txx9aclc_pcm_prepare(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct txx9aclc_dmadata *dmadata = runtime->private_data; - - dmadata->dma_addr = runtime->dma_addr; - dmadata->buffer_bytes = snd_pcm_lib_buffer_bytes(substream); - dmadata->period_bytes = snd_pcm_lib_period_bytes(substream); - - if (dmadata->buffer_bytes == dmadata->period_bytes) { - dmadata->frag_bytes = dmadata->period_bytes >> 1; - dmadata->frags = 2; - } else { - dmadata->frag_bytes = dmadata->period_bytes; - dmadata->frags = dmadata->buffer_bytes / dmadata->period_bytes; - } - dmadata->frag_count = 0; - dmadata->pos = 0; - return 0; -} - -static void txx9aclc_dma_complete(void *arg) -{ - struct txx9aclc_dmadata *dmadata = arg; - unsigned long flags; - - /* dma completion handler cannot submit new operations */ - spin_lock_irqsave(&dmadata->dma_lock, flags); - if (dmadata->frag_count >= 0) { - dmadata->dmacount--; - if (!warn_on(dmadata->dmacount < 0)) - queue_work(system_highpri_wq, &dmadata->work); - } - spin_unlock_irqrestore(&dmadata->dma_lock, flags); -} - -static struct dma_async_tx_descriptor * -txx9aclc_dma_submit(struct txx9aclc_dmadata *dmadata, dma_addr_t buf_dma_addr) -{ - struct dma_chan *chan = dmadata->dma_chan; - struct dma_async_tx_descriptor *desc; - struct scatterlist sg; - - sg_init_table(&sg, 1); - sg_set_page(&sg, pfn_to_page(pfn_down(buf_dma_addr)), - dmadata->frag_bytes, buf_dma_addr & (page_size - 1)); - sg_dma_address(&sg) = buf_dma_addr; - desc = dmaengine_prep_slave_sg(chan, &sg, 1, - dmadata->substream->stream == sndrv_pcm_stream_playback ? - dma_mem_to_dev : dma_dev_to_mem, - dma_prep_interrupt | dma_ctrl_ack); - if (!desc) { - dev_err(&chan->dev->device, "cannot prepare slave dma "); - return null; - } - desc->callback = txx9aclc_dma_complete; - desc->callback_param = dmadata; - dmaengine_submit(desc); - return desc; -} - -#define nr_dma_chain 2 - -static void txx9aclc_dma_work(struct work_struct *work) -{ - struct txx9aclc_dmadata *dmadata = - container_of(work, struct txx9aclc_dmadata, work); - struct dma_chan *chan = dmadata->dma_chan; - struct dma_async_tx_descriptor *desc; - struct snd_pcm_substream *substream = dmadata->substream; - u32 ctlbit = substream->stream == sndrv_pcm_stream_playback ? - acctl_audodma : acctl_audidma; - int i; - unsigned long flags; - - spin_lock_irqsave(&dmadata->dma_lock, flags); - if (dmadata->frag_count < 0) { - struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; - void __iomem *base = drvdata->base; - - spin_unlock_irqrestore(&dmadata->dma_lock, flags); - dmaengine_terminate_all(chan); - /* first time */ - for (i = 0; i < nr_dma_chain; i++) { - desc = txx9aclc_dma_submit(dmadata, - dmadata->dma_addr + i * dmadata->frag_bytes); - if (!desc) - return; - } - dmadata->dmacount = nr_dma_chain; - dma_async_issue_pending(chan); - spin_lock_irqsave(&dmadata->dma_lock, flags); - __raw_writel(ctlbit, base + acctlen); - dmadata->frag_count = nr_dma_chain % dmadata->frags; - spin_unlock_irqrestore(&dmadata->dma_lock, flags); - return; - } - if (warn_on(dmadata->dmacount >= nr_dma_chain)) { - spin_unlock_irqrestore(&dmadata->dma_lock, flags); - return; - } - while (dmadata->dmacount < nr_dma_chain) { - dmadata->dmacount++; - spin_unlock_irqrestore(&dmadata->dma_lock, flags); - desc = txx9aclc_dma_submit(dmadata, - dmadata->dma_addr + - dmadata->frag_count * dmadata->frag_bytes); - if (!desc) - return; - dma_async_issue_pending(chan); - - spin_lock_irqsave(&dmadata->dma_lock, flags); - dmadata->frag_count++; - dmadata->frag_count %= dmadata->frags; - dmadata->pos += dmadata->frag_bytes; - dmadata->pos %= dmadata->buffer_bytes; - if ((dmadata->frag_count * dmadata->frag_bytes) % - dmadata->period_bytes == 0) - snd_pcm_period_elapsed(substream); - } - spin_unlock_irqrestore(&dmadata->dma_lock, flags); -} - -static int txx9aclc_pcm_trigger(struct snd_soc_component *component, - struct snd_pcm_substream *substream, int cmd) -{ - struct txx9aclc_dmadata *dmadata = substream->runtime->private_data; - struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; - void __iomem *base = drvdata->base; - unsigned long flags; - int ret = 0; - u32 ctlbit = substream->stream == sndrv_pcm_stream_playback ? - acctl_audodma : acctl_audidma; - - spin_lock_irqsave(&dmadata->dma_lock, flags); - switch (cmd) { - case sndrv_pcm_trigger_start: - dmadata->frag_count = -1; - queue_work(system_highpri_wq, &dmadata->work); - break; - case sndrv_pcm_trigger_stop: - case sndrv_pcm_trigger_pause_push: - case sndrv_pcm_trigger_suspend: - __raw_writel(ctlbit, base + acctldis); - break; - case sndrv_pcm_trigger_pause_release: - case sndrv_pcm_trigger_resume: - __raw_writel(ctlbit, base + acctlen); - break; - default: - ret = -einval; - } - spin_unlock_irqrestore(&dmadata->dma_lock, flags); - return ret; -} - -static snd_pcm_uframes_t -txx9aclc_pcm_pointer(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct txx9aclc_dmadata *dmadata = substream->runtime->private_data; - - return bytes_to_frames(substream->runtime, dmadata->pos); -} - -static int txx9aclc_pcm_open(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct txx9aclc_soc_device *dev = &txx9aclc_soc_device; - struct txx9aclc_dmadata *dmadata = &dev->dmadata[substream->stream]; - int ret; - - ret = snd_soc_set_runtime_hwparams(substream, &txx9aclc_pcm_hardware); - if (ret) - return ret; - /* ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(substream->runtime, - sndrv_pcm_hw_param_periods); - if (ret < 0) - return ret; - substream->runtime->private_data = dmadata; - return 0; -} - -static int txx9aclc_pcm_close(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct txx9aclc_dmadata *dmadata = substream->runtime->private_data; - struct dma_chan *chan = dmadata->dma_chan; - - dmadata->frag_count = -1; - dmaengine_terminate_all(chan); - return 0; -} - -static int txx9aclc_pcm_new(struct snd_soc_component *component, - struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0); - struct snd_pcm *pcm = rtd->pcm; - struct platform_device *pdev = to_platform_device(component->dev); - struct txx9aclc_soc_device *dev; - struct resource *r; - int i; - int ret; - - /* at this point onwards the ac97 component has probed and this will be valid */ - dev = snd_soc_dai_get_drvdata(dai); - - dev->dmadata[0].stream = sndrv_pcm_stream_playback; - dev->dmadata[1].stream = sndrv_pcm_stream_capture; - for (i = 0; i < 2; i++) { - r = platform_get_resource(pdev, ioresource_dma, i); - if (!r) { - ret = -ebusy; - goto exit; - } - dev->dmadata[i].dma_res = r; - ret = txx9aclc_dma_init(dev, &dev->dmadata[i]); - if (ret) - goto exit; - } - - snd_pcm_set_managed_buffer_all(pcm, sndrv_dma_type_dev, - card->dev, 64 * 1024, 4 * 1024 * 1024); - return 0; - -exit: - for (i = 0; i < 2; i++) { - if (dev->dmadata[i].dma_chan) - dma_release_channel(dev->dmadata[i].dma_chan); - dev->dmadata[i].dma_chan = null; - } - return ret; -} - -static bool filter(struct dma_chan *chan, void *param) -{ - struct txx9aclc_dmadata *dmadata = param; - char *devname; - bool found = false; - - devname = kasprintf(gfp_kernel, "%s.%d", dmadata->dma_res->name, - (int)dmadata->dma_res->start); - if (strcmp(dev_name(chan->device->dev), devname) == 0) { - chan->private = &dmadata->dma_slave; - found = true; - } - kfree(devname); - return found; -} - -static int txx9aclc_dma_init(struct txx9aclc_soc_device *dev, - struct txx9aclc_dmadata *dmadata) -{ - struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; - struct txx9dmac_slave *ds = &dmadata->dma_slave; - dma_cap_mask_t mask; - - spin_lock_init(&dmadata->dma_lock); - - ds->reg_width = sizeof(u32); - if (dmadata->stream == sndrv_pcm_stream_playback) { - ds->tx_reg = drvdata->physbase + acaudodat; - ds->rx_reg = 0; - } else { - ds->tx_reg = 0; - ds->rx_reg = drvdata->physbase + acaudidat; - } - - /* try to grab a dma channel */ - dma_cap_zero(mask); - dma_cap_set(dma_slave, mask); - dmadata->dma_chan = dma_request_channel(mask, filter, dmadata); - if (!dmadata->dma_chan) { - printk(kern_err - "dma channel for %s is not available ", - dmadata->stream == sndrv_pcm_stream_playback ? - "playback" : "capture"); - return -ebusy; - } - init_work(&dmadata->work, txx9aclc_dma_work); - return 0; -} - -static int txx9aclc_pcm_probe(struct snd_soc_component *component) -{ - snd_soc_component_set_drvdata(component, &txx9aclc_soc_device); - return 0; -} - -static void txx9aclc_pcm_remove(struct snd_soc_component *component) -{ - struct txx9aclc_soc_device *dev = snd_soc_component_get_drvdata(component); - struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; - void __iomem *base = drvdata->base; - int i; - - /* disable all fifo dmas */ - __raw_writel(acctl_audodma | acctl_audidma, base + acctldis); - /* dummy r/w to clear pending dmareq if any */ - __raw_writel(__raw_readl(base + acaudidat), base + acaudodat); - - for (i = 0; i < 2; i++) { - struct txx9aclc_dmadata *dmadata = &dev->dmadata[i]; - struct dma_chan *chan = dmadata->dma_chan; - - if (chan) { - dmadata->frag_count = -1; - dmaengine_terminate_all(chan); - dma_release_channel(chan); - } - dev->dmadata[i].dma_chan = null; - } -} - -static const struct snd_soc_component_driver txx9aclc_soc_component = { - .name = drv_name, - .probe = txx9aclc_pcm_probe, - .remove = txx9aclc_pcm_remove, - .open = txx9aclc_pcm_open, - .close = txx9aclc_pcm_close, - .hw_params = txx9aclc_pcm_hw_params, - .prepare = txx9aclc_pcm_prepare, - .trigger = txx9aclc_pcm_trigger, - .pointer = txx9aclc_pcm_pointer, - .pcm_construct = txx9aclc_pcm_new, -}; - -static int txx9aclc_soc_platform_probe(struct platform_device *pdev) -{ - return devm_snd_soc_register_component(&pdev->dev, - &txx9aclc_soc_component, null, 0); -} - -static struct platform_driver txx9aclc_pcm_driver = { - .driver = { - .name = "txx9aclc-pcm-audio", - }, - - .probe = txx9aclc_soc_platform_probe, -}; - -module_platform_driver(txx9aclc_pcm_driver); - -module_author("atsushi nemoto <anemo@mba.ocn.ne.jp>"); -module_description("txx9 aclc audio dma driver"); -module_license("gpl"); diff --git a/sound/soc/txx9/txx9aclc.h b/sound/soc/txx9/txx9aclc.h --- a/sound/soc/txx9/txx9aclc.h +++ /dev/null -/* spdx-license-identifier: gpl-2.0-only */ -/* - * txx9 soc ac link controller - */ - -#ifndef __txx9aclc_h -#define __txx9aclc_h - -#include <linux/interrupt.h> -#include <asm/txx9/dmac.h> - -#define acctlen 0x00 /* control enable */ -#define acctldis 0x04 /* control disable */ -#define acctl_enlink 0x00000001 /* enable/disable ac-link */ -#define acctl_audodma 0x00000100 /* audodma enable/disable */ -#define acctl_audidma 0x00001000 /* audidma enable/disable */ -#define acctl_audoehlt 0x00010000 /* audo error halt - enable/disable */ -#define acctl_audiehlt 0x00100000 /* audi error halt - enable/disable */ -#define acregacc 0x08 /* codec register access */ -#define acregacc_dat_shift 0 /* data field */ -#define acregacc_reg_shift 16 /* address field */ -#define acregacc_codecid_shift 24 /* codec id field */ -#define acregacc_read 0x80000000 /* codec read */ -#define acregacc_write 0x00000000 /* codec write */ -#define acintsts 0x10 /* interrupt status */ -#define acintmsts 0x14 /* interrupt masked status */ -#define acinten 0x18 /* interrupt enable */ -#define acintdis 0x1c /* interrupt disable */ -#define acint_codecrdy(n) (0x00000001 << (n)) /* codecn ready */ -#define acint_regaccrdy 0x00000010 /* acregacc ready */ -#define acint_audoerr 0x00000100 /* audo underrun error */ -#define acint_audierr 0x00001000 /* audi overrun error */ -#define acdmasts 0x80 /* dma request status */ -#define acdma_audo 0x00000001 /* audodma pending */ -#define acdma_audi 0x00000010 /* audidma pending */ -#define acaudodat 0xa0 /* audio out data */ -#define acaudidat 0xb0 /* audio in data */ -#define acrevid 0xfc /* revision id */ - -struct txx9aclc_dmadata { - struct resource *dma_res; - struct txx9dmac_slave dma_slave; - struct dma_chan *dma_chan; - struct work_struct work; - spinlock_t dma_lock; - int stream; /* sndrv_pcm_stream_playback or sndrv_pcm_stream_capture */ - struct snd_pcm_substream *substream; - unsigned long pos; - dma_addr_t dma_addr; - unsigned long buffer_bytes; - unsigned long period_bytes; - unsigned long frag_bytes; - int frags; - int frag_count; - int dmacount; -}; - -struct txx9aclc_plat_drvdata { - void __iomem *base; - u64 physbase; -}; - -static inline struct txx9aclc_plat_drvdata *txx9aclc_get_plat_drvdata( - struct snd_soc_dai *dai) -{ - return dev_get_drvdata(dai->dev); -} - -#endif /* __txx9aclc_h */
Audio
a8644292ea46064f990e4a3c4585bdb294c0d89a
thomas bogendoerfer
sound
soc
txx9
asoc: remove sirf prima/atlas drivers
the csr sirf prima2/atlas platforms are getting removed, so this driver is no longer needed.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
remove sirf prima/atlas drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ']
['c', 'h', 'kconfig', 'txt', 'makefile']
12
0
1,625
--- diff --git a/documentation/devicetree/bindings/sound/sirf-audio-codec.txt b/documentation/devicetree/bindings/sound/sirf-audio-codec.txt --- a/documentation/devicetree/bindings/sound/sirf-audio-codec.txt +++ /dev/null -sirf internal audio codec - -required properties: - - - compatible : "sirf,atlas6-audio-codec" or "sirf,prima2-audio-codec" - - - reg : the register address of the device. - - - clocks: the clock of sirf internal audio codec - -example: - -audiocodec: audiocodec@b0040000 { - compatible = "sirf,atlas6-audio-codec"; - reg = <0xb0040000 0x10000>; - clocks = <&clks 27>; -}; diff --git a/documentation/devicetree/bindings/sound/sirf-usp.txt b/documentation/devicetree/bindings/sound/sirf-usp.txt --- a/documentation/devicetree/bindings/sound/sirf-usp.txt +++ /dev/null -* sirf soc usp module - -required properties: -- compatible: "sirf,prima2-usp-pcm" -- reg: base address and size entries: -- dmas: list of dma controller phandle and dma request line ordered pairs. -- dma-names: identifier string for each dma request line in the dmas property. - these strings correspond 1:1 with the ordered pairs in dmas. - - one of the dma channels will be responsible for transmission (should be - named "tx") and one for reception (should be named "rx"). - -- clocks: usp controller clock source -- pinctrl-names: must contain a "default" entry. -- pinctrl-nnn: one property must exist for each entry in pinctrl-names. - -example: -usp0: usp@b0080000 { - compatible = "sirf,prima2-usp-pcm"; - reg = <0xb0080000 0x10000>; - clocks = <&clks 28>; - dmas = <&dmac1 1>, <&dmac1 2>; - dma-names = "rx", "tx"; - pinctrl-names = "default"; - pinctrl-0 = <&usp0_only_utfs_pins_a>; -}; - diff --git a/sound/soc/kconfig b/sound/soc/kconfig --- a/sound/soc/kconfig +++ b/sound/soc/kconfig -source "sound/soc/sirf/kconfig" diff --git a/sound/soc/makefile b/sound/soc/makefile --- a/sound/soc/makefile +++ b/sound/soc/makefile -obj-$(config_snd_soc) += sirf/ diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile -snd-soc-sirf-audio-codec-objs := sirf-audio-codec.o -obj-$(config_snd_soc_sirf_audio_codec) += sirf-audio-codec.o diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c --- a/sound/soc/codecs/sirf-audio-codec.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-or-later -/* - * sirf audio codec driver - * - * copyright (c) 2011 cambridge silicon radio limited, a csr plc group company. - */ - -#include <linux/module.h> -#include <linux/platform_device.h> -#include <linux/pm_runtime.h> -#include <linux/of.h> -#include <linux/of_device.h> -#include <linux/clk.h> -#include <linux/delay.h> -#include <linux/io.h> -#include <linux/regmap.h> -#include <sound/core.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> -#include <sound/initval.h> -#include <sound/tlv.h> -#include <sound/soc.h> -#include <sound/dmaengine_pcm.h> - -#include "sirf-audio-codec.h" - -struct sirf_audio_codec { - struct clk *clk; - struct regmap *regmap; - u32 reg_ctrl0, reg_ctrl1; -}; - -static const char * const input_mode_mux[] = {"single-ended", - "differential"}; - -static const struct soc_enum input_mode_mux_enum = - soc_enum_single(audio_ic_codec_ctrl1, 4, 2, input_mode_mux); - -static const struct snd_kcontrol_new sirf_audio_codec_input_mode_control = - soc_dapm_enum("route", input_mode_mux_enum); - -static const declare_tlv_db_scale(playback_vol_tlv, -12400, 100, 0); -static const declare_tlv_db_scale(capture_vol_tlv_prima2, 500, 100, 0); -static const declare_tlv_db_range(capture_vol_tlv_atlas6, - 0, 7, tlv_db_scale_item(-100, 100, 0), - 0x22, 0x3f, tlv_db_scale_item(700, 100, 0), -); - -static struct snd_kcontrol_new volume_controls_atlas6[] = { - soc_double_tlv("playback volume", audio_ic_codec_ctrl0, 21, 14, - 0x7f, 0, playback_vol_tlv), - soc_double_tlv("capture volume", audio_ic_codec_ctrl1, 16, 10, - 0x3f, 0, capture_vol_tlv_atlas6), -}; - -static struct snd_kcontrol_new volume_controls_prima2[] = { - soc_double_tlv("speaker volume", audio_ic_codec_ctrl0, 21, 14, - 0x7f, 0, playback_vol_tlv), - soc_double_tlv("capture volume", audio_ic_codec_ctrl1, 15, 10, - 0x1f, 0, capture_vol_tlv_prima2), -}; - -static struct snd_kcontrol_new left_input_path_controls[] = { - soc_dapm_single("line left switch", audio_ic_codec_ctrl1, 6, 1, 0), - soc_dapm_single("mic left switch", audio_ic_codec_ctrl1, 3, 1, 0), -}; - -static struct snd_kcontrol_new right_input_path_controls[] = { - soc_dapm_single("line right switch", audio_ic_codec_ctrl1, 5, 1, 0), - soc_dapm_single("mic right switch", audio_ic_codec_ctrl1, 2, 1, 0), -}; - -static struct snd_kcontrol_new left_dac_to_hp_left_amp_switch_control = - soc_dapm_single("switch", audio_ic_codec_ctrl0, 9, 1, 0); - -static struct snd_kcontrol_new left_dac_to_hp_right_amp_switch_control = - soc_dapm_single("switch", audio_ic_codec_ctrl0, 8, 1, 0); - -static struct snd_kcontrol_new right_dac_to_hp_left_amp_switch_control = - soc_dapm_single("switch", audio_ic_codec_ctrl0, 7, 1, 0); - -static struct snd_kcontrol_new right_dac_to_hp_right_amp_switch_control = - soc_dapm_single("switch", audio_ic_codec_ctrl0, 6, 1, 0); - -static struct snd_kcontrol_new left_dac_to_speaker_lineout_switch_control = - soc_dapm_single("switch", audio_ic_codec_ctrl0, 11, 1, 0); - -static struct snd_kcontrol_new right_dac_to_speaker_lineout_switch_control = - soc_dapm_single("switch", audio_ic_codec_ctrl0, 10, 1, 0); - -/* after enable adc, delay 200ms to avoid pop noise */ -static int adc_enable_delay_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - switch (event) { - case snd_soc_dapm_post_pmu: - msleep(200); - break; - default: - break; - } - - return 0; -} - -static void enable_and_reset_codec(struct regmap *regmap, - u32 codec_enable_bits, u32 codec_reset_bits) -{ - regmap_update_bits(regmap, audio_ic_codec_ctrl1, - codec_enable_bits | codec_reset_bits, - codec_enable_bits); - msleep(20); - regmap_update_bits(regmap, audio_ic_codec_ctrl1, - codec_reset_bits, codec_reset_bits); -} - -static int atlas6_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ -#define atlas6_codec_enable_bits (1 << 29) -#define atlas6_codec_reset_bits (1 << 28) - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - struct sirf_audio_codec *sirf_audio_codec = snd_soc_component_get_drvdata(component); - switch (event) { - case snd_soc_dapm_pre_pmu: - enable_and_reset_codec(sirf_audio_codec->regmap, - atlas6_codec_enable_bits, atlas6_codec_reset_bits); - break; - case snd_soc_dapm_post_pmd: - regmap_update_bits(sirf_audio_codec->regmap, - audio_ic_codec_ctrl1, atlas6_codec_enable_bits, 0); - break; - default: - break; - } - - return 0; -} - -static int prima2_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ -#define prima2_codec_enable_bits (1 << 27) -#define prima2_codec_reset_bits (1 << 26) - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - struct sirf_audio_codec *sirf_audio_codec = snd_soc_component_get_drvdata(component); - switch (event) { - case snd_soc_dapm_post_pmu: - enable_and_reset_codec(sirf_audio_codec->regmap, - prima2_codec_enable_bits, prima2_codec_reset_bits); - break; - case snd_soc_dapm_post_pmd: - regmap_update_bits(sirf_audio_codec->regmap, - audio_ic_codec_ctrl1, prima2_codec_enable_bits, 0); - break; - default: - break; - } - - return 0; -} - -static const struct snd_soc_dapm_widget atlas6_output_driver_dapm_widgets[] = { - snd_soc_dapm_out_drv("hp left driver", audio_ic_codec_ctrl1, - 25, 0, null, 0), - snd_soc_dapm_out_drv("hp right driver", audio_ic_codec_ctrl1, - 26, 0, null, 0), - snd_soc_dapm_out_drv("speaker driver", audio_ic_codec_ctrl1, - 27, 0, null, 0), -}; - -static const struct snd_soc_dapm_widget prima2_output_driver_dapm_widgets[] = { - snd_soc_dapm_out_drv("hp left driver", audio_ic_codec_ctrl1, - 23, 0, null, 0), - snd_soc_dapm_out_drv("hp right driver", audio_ic_codec_ctrl1, - 24, 0, null, 0), - snd_soc_dapm_out_drv("speaker driver", audio_ic_codec_ctrl1, - 25, 0, null, 0), -}; - -static const struct snd_soc_dapm_widget atlas6_codec_clock_dapm_widget = - snd_soc_dapm_supply("codecclk", snd_soc_nopm, 0, 0, - atlas6_codec_enable_and_reset_event, - snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd); - -static const struct snd_soc_dapm_widget prima2_codec_clock_dapm_widget = - snd_soc_dapm_supply("codecclk", snd_soc_nopm, 0, 0, - prima2_codec_enable_and_reset_event, - snd_soc_dapm_pre_pmu | snd_soc_dapm_post_pmd); - -static const struct snd_soc_dapm_widget sirf_audio_codec_dapm_widgets[] = { - snd_soc_dapm_dac("dac left", null, audio_ic_codec_ctrl0, 1, 0), - snd_soc_dapm_dac("dac right", null, audio_ic_codec_ctrl0, 0, 0), - snd_soc_dapm_switch("left dac to hp left amp", snd_soc_nopm, 0, 0, - &left_dac_to_hp_left_amp_switch_control), - snd_soc_dapm_switch("left dac to hp right amp", snd_soc_nopm, 0, 0, - &left_dac_to_hp_right_amp_switch_control), - snd_soc_dapm_switch("right dac to hp left amp", snd_soc_nopm, 0, 0, - &right_dac_to_hp_left_amp_switch_control), - snd_soc_dapm_switch("right dac to hp right amp", snd_soc_nopm, 0, 0, - &right_dac_to_hp_right_amp_switch_control), - snd_soc_dapm_out_drv("hp amp left driver", audio_ic_codec_ctrl0, 3, 0, - null, 0), - snd_soc_dapm_out_drv("hp amp right driver", audio_ic_codec_ctrl0, 3, 0, - null, 0), - - snd_soc_dapm_switch("left dac to speaker lineout", snd_soc_nopm, 0, 0, - &left_dac_to_speaker_lineout_switch_control), - snd_soc_dapm_switch("right dac to speaker lineout", snd_soc_nopm, 0, 0, - &right_dac_to_speaker_lineout_switch_control), - snd_soc_dapm_out_drv("speaker amp driver", audio_ic_codec_ctrl0, 4, 0, - null, 0), - - snd_soc_dapm_output("hpoutl"), - snd_soc_dapm_output("hpoutr"), - snd_soc_dapm_output("spkout"), - - snd_soc_dapm_adc_e("adc left", null, audio_ic_codec_ctrl1, 8, 0, - adc_enable_delay_event, snd_soc_dapm_post_pmu), - snd_soc_dapm_adc_e("adc right", null, audio_ic_codec_ctrl1, 7, 0, - adc_enable_delay_event, snd_soc_dapm_post_pmu), - snd_soc_dapm_mixer("left pga mixer", audio_ic_codec_ctrl1, 1, 0, - &left_input_path_controls[0], - array_size(left_input_path_controls)), - snd_soc_dapm_mixer("right pga mixer", audio_ic_codec_ctrl1, 0, 0, - &right_input_path_controls[0], - array_size(right_input_path_controls)), - - snd_soc_dapm_mux("mic input mode mux", snd_soc_nopm, 0, 0, - &sirf_audio_codec_input_mode_control), - snd_soc_dapm_micbias("mic bias", audio_ic_codec_pwr, 3, 0), - snd_soc_dapm_input("micin1"), - snd_soc_dapm_input("micin2"), - snd_soc_dapm_input("linein1"), - snd_soc_dapm_input("linein2"), - - snd_soc_dapm_supply("hsl phase opposite", audio_ic_codec_ctrl0, - 30, 0, null, 0), -}; - -static const struct snd_soc_dapm_route sirf_audio_codec_map[] = { - {"spkout", null, "speaker driver"}, - {"speaker driver", null, "speaker amp driver"}, - {"speaker amp driver", null, "left dac to speaker lineout"}, - {"speaker amp driver", null, "right dac to speaker lineout"}, - {"left dac to speaker lineout", "switch", "dac left"}, - {"right dac to speaker lineout", "switch", "dac right"}, - {"hpoutl", null, "hp left driver"}, - {"hpoutr", null, "hp right driver"}, - {"hp left driver", null, "hp amp left driver"}, - {"hp right driver", null, "hp amp right driver"}, - {"hp amp left driver", null, "right dac to hp left amp"}, - {"hp amp right driver", null , "right dac to hp right amp"}, - {"hp amp left driver", null, "left dac to hp left amp"}, - {"hp amp right driver", null , "right dac to hp right amp"}, - {"right dac to hp left amp", "switch", "dac left"}, - {"right dac to hp right amp", "switch", "dac right"}, - {"left dac to hp left amp", "switch", "dac left"}, - {"left dac to hp right amp", "switch", "dac right"}, - {"dac left", null, "codecclk"}, - {"dac right", null, "codecclk"}, - {"dac left", null, "playback"}, - {"dac right", null, "playback"}, - {"dac left", null, "hsl phase opposite"}, - {"dac right", null, "hsl phase opposite"}, - - {"capture", null, "adc left"}, - {"capture", null, "adc right"}, - {"adc left", null, "codecclk"}, - {"adc right", null, "codecclk"}, - {"adc left", null, "left pga mixer"}, - {"adc right", null, "right pga mixer"}, - {"left pga mixer", "line left switch", "linein2"}, - {"right pga mixer", "line right switch", "linein1"}, - {"left pga mixer", "mic left switch", "micin2"}, - {"right pga mixer", "mic right switch", "mic input mode mux"}, - {"mic input mode mux", "single-ended", "micin1"}, - {"mic input mode mux", "differential", "micin1"}, -}; - -static void sirf_audio_codec_tx_enable(struct sirf_audio_codec *sirf_audio_codec) -{ - regmap_update_bits(sirf_audio_codec->regmap, audio_port_ic_txfifo_op, - audio_fifo_reset, audio_fifo_reset); - regmap_update_bits(sirf_audio_codec->regmap, audio_port_ic_txfifo_op, - audio_fifo_reset, ~audio_fifo_reset); - regmap_write(sirf_audio_codec->regmap, audio_port_ic_txfifo_int_msk, 0); - regmap_write(sirf_audio_codec->regmap, audio_port_ic_txfifo_op, 0); - regmap_update_bits(sirf_audio_codec->regmap, audio_port_ic_txfifo_op, - audio_fifo_start, audio_fifo_start); - regmap_update_bits(sirf_audio_codec->regmap, - audio_port_ic_codec_tx_ctrl, ic_tx_enable, ic_tx_enable); -} - -static void sirf_audio_codec_tx_disable(struct sirf_audio_codec *sirf_audio_codec) -{ - regmap_write(sirf_audio_codec->regmap, audio_port_ic_txfifo_op, 0); - regmap_update_bits(sirf_audio_codec->regmap, - audio_port_ic_codec_tx_ctrl, ic_tx_enable, ~ic_tx_enable); -} - -static void sirf_audio_codec_rx_enable(struct sirf_audio_codec *sirf_audio_codec, - int channels) -{ - regmap_update_bits(sirf_audio_codec->regmap, audio_port_ic_rxfifo_op, - audio_fifo_reset, audio_fifo_reset); - regmap_update_bits(sirf_audio_codec->regmap, audio_port_ic_rxfifo_op, - audio_fifo_reset, ~audio_fifo_reset); - regmap_write(sirf_audio_codec->regmap, - audio_port_ic_rxfifo_int_msk, 0); - regmap_write(sirf_audio_codec->regmap, audio_port_ic_rxfifo_op, 0); - regmap_update_bits(sirf_audio_codec->regmap, audio_port_ic_rxfifo_op, - audio_fifo_start, audio_fifo_start); - if (channels == 1) - regmap_update_bits(sirf_audio_codec->regmap, - audio_port_ic_codec_rx_ctrl, - ic_rx_enable_mono, ic_rx_enable_mono); - else - regmap_update_bits(sirf_audio_codec->regmap, - audio_port_ic_codec_rx_ctrl, - ic_rx_enable_stereo, ic_rx_enable_stereo); -} - -static void sirf_audio_codec_rx_disable(struct sirf_audio_codec *sirf_audio_codec) -{ - regmap_update_bits(sirf_audio_codec->regmap, - audio_port_ic_codec_rx_ctrl, - ic_rx_enable_stereo, ~ic_rx_enable_stereo); -} - -static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream, - int cmd, - struct snd_soc_dai *dai) -{ - struct snd_soc_component *component = dai->component; - struct sirf_audio_codec *sirf_audio_codec = snd_soc_component_get_drvdata(component); - int playback = substream->stream == sndrv_pcm_stream_playback; - - /* - * this is a workaround, when stop playback, - * need disable hp amp, avoid the current noise. - */ - switch (cmd) { - case sndrv_pcm_trigger_stop: - case sndrv_pcm_trigger_suspend: - case sndrv_pcm_trigger_pause_push: - if (playback) { - snd_soc_component_update_bits(component, audio_ic_codec_ctrl0, - ic_hslen | ic_hsren, 0); - sirf_audio_codec_tx_disable(sirf_audio_codec); - } else - sirf_audio_codec_rx_disable(sirf_audio_codec); - break; - case sndrv_pcm_trigger_start: - case sndrv_pcm_trigger_resume: - case sndrv_pcm_trigger_pause_release: - if (playback) { - sirf_audio_codec_tx_enable(sirf_audio_codec); - snd_soc_component_update_bits(component, audio_ic_codec_ctrl0, - ic_hslen | ic_hsren, ic_hslen | ic_hsren); - } else - sirf_audio_codec_rx_enable(sirf_audio_codec, - substream->runtime->channels); - break; - default: - return -einval; - } - - return 0; -} - -static const struct snd_soc_dai_ops sirf_audio_codec_dai_ops = { - .trigger = sirf_audio_codec_trigger, -}; - -static struct snd_soc_dai_driver sirf_audio_codec_dai = { - .name = "sirf-audio-codec", - .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 = 1, - .channels_max = 2, - .rates = sndrv_pcm_rate_48000, - .formats = sndrv_pcm_fmtbit_s16_le, - }, - .ops = &sirf_audio_codec_dai_ops, -}; - -static int sirf_audio_codec_probe(struct snd_soc_component *component) -{ - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - - pm_runtime_enable(component->dev); - - if (of_device_is_compatible(component->dev->of_node, "sirf,prima2-audio-codec")) { - snd_soc_dapm_new_controls(dapm, - prima2_output_driver_dapm_widgets, - array_size(prima2_output_driver_dapm_widgets)); - snd_soc_dapm_new_controls(dapm, - &prima2_codec_clock_dapm_widget, 1); - return snd_soc_add_component_controls(component, - volume_controls_prima2, - array_size(volume_controls_prima2)); - } - if (of_device_is_compatible(component->dev->of_node, "sirf,atlas6-audio-codec")) { - snd_soc_dapm_new_controls(dapm, - atlas6_output_driver_dapm_widgets, - array_size(atlas6_output_driver_dapm_widgets)); - snd_soc_dapm_new_controls(dapm, - &atlas6_codec_clock_dapm_widget, 1); - return snd_soc_add_component_controls(component, - volume_controls_atlas6, - array_size(volume_controls_atlas6)); - } - - return -einval; -} - -static void sirf_audio_codec_remove(struct snd_soc_component *component) -{ - pm_runtime_disable(component->dev); -} - -static const struct snd_soc_component_driver soc_codec_device_sirf_audio_codec = { - .probe = sirf_audio_codec_probe, - .remove = sirf_audio_codec_remove, - .dapm_widgets = sirf_audio_codec_dapm_widgets, - .num_dapm_widgets = array_size(sirf_audio_codec_dapm_widgets), - .dapm_routes = sirf_audio_codec_map, - .num_dapm_routes = array_size(sirf_audio_codec_map), - .use_pmdown_time = 1, - .endianness = 1, - .non_legacy_dai_naming = 1, -}; - -static const struct of_device_id sirf_audio_codec_of_match[] = { - { .compatible = "sirf,prima2-audio-codec" }, - { .compatible = "sirf,atlas6-audio-codec" }, - {} -}; -module_device_table(of, sirf_audio_codec_of_match); - -static const struct regmap_config sirf_audio_codec_regmap_config = { - .reg_bits = 32, - .reg_stride = 4, - .val_bits = 32, - .max_register = audio_port_ic_rxfifo_int_msk, - .cache_type = regcache_none, -}; - -static int sirf_audio_codec_driver_probe(struct platform_device *pdev) -{ - int ret; - struct sirf_audio_codec *sirf_audio_codec; - void __iomem *base; - - sirf_audio_codec = devm_kzalloc(&pdev->dev, - sizeof(struct sirf_audio_codec), gfp_kernel); - if (!sirf_audio_codec) - return -enomem; - - platform_set_drvdata(pdev, sirf_audio_codec); - - base = devm_platform_ioremap_resource(pdev, 0); - if (is_err(base)) - return ptr_err(base); - - sirf_audio_codec->regmap = devm_regmap_init_mmio(&pdev->dev, base, - &sirf_audio_codec_regmap_config); - if (is_err(sirf_audio_codec->regmap)) - return ptr_err(sirf_audio_codec->regmap); - - sirf_audio_codec->clk = devm_clk_get(&pdev->dev, null); - if (is_err(sirf_audio_codec->clk)) { - dev_err(&pdev->dev, "get clock failed. "); - return ptr_err(sirf_audio_codec->clk); - } - - ret = clk_prepare_enable(sirf_audio_codec->clk); - if (ret) { - dev_err(&pdev->dev, "enable clock failed. "); - return ret; - } - - ret = devm_snd_soc_register_component(&(pdev->dev), - &soc_codec_device_sirf_audio_codec, - &sirf_audio_codec_dai, 1); - if (ret) { - dev_err(&pdev->dev, "register audio codec dai failed. "); - goto err_clk_put; - } - - /* - * always open charge pump, if not, when the charge pump closed the - * adc will not stable - */ - regmap_update_bits(sirf_audio_codec->regmap, audio_ic_codec_ctrl0, - ic_cpfreq, ic_cpfreq); - - if (of_device_is_compatible(pdev->dev.of_node, "sirf,atlas6-audio-codec")) - regmap_update_bits(sirf_audio_codec->regmap, - audio_ic_codec_ctrl0, ic_cpen, ic_cpen); - return 0; - -err_clk_put: - clk_disable_unprepare(sirf_audio_codec->clk); - return ret; -} - -static int sirf_audio_codec_driver_remove(struct platform_device *pdev) -{ - struct sirf_audio_codec *sirf_audio_codec = platform_get_drvdata(pdev); - - clk_disable_unprepare(sirf_audio_codec->clk); - - return 0; -} - -#ifdef config_pm_sleep -static int sirf_audio_codec_suspend(struct device *dev) -{ - struct sirf_audio_codec *sirf_audio_codec = dev_get_drvdata(dev); - - regmap_read(sirf_audio_codec->regmap, audio_ic_codec_ctrl0, - &sirf_audio_codec->reg_ctrl0); - regmap_read(sirf_audio_codec->regmap, audio_ic_codec_ctrl1, - &sirf_audio_codec->reg_ctrl1); - clk_disable_unprepare(sirf_audio_codec->clk); - - return 0; -} - -static int sirf_audio_codec_resume(struct device *dev) -{ - struct sirf_audio_codec *sirf_audio_codec = dev_get_drvdata(dev); - int ret; - - ret = clk_prepare_enable(sirf_audio_codec->clk); - if (ret) - return ret; - - regmap_write(sirf_audio_codec->regmap, audio_ic_codec_ctrl0, - sirf_audio_codec->reg_ctrl0); - regmap_write(sirf_audio_codec->regmap, audio_ic_codec_ctrl1, - sirf_audio_codec->reg_ctrl1); - - return 0; -} -#endif - -static const struct dev_pm_ops sirf_audio_codec_pm_ops = { - set_system_sleep_pm_ops(sirf_audio_codec_suspend, sirf_audio_codec_resume) -}; - -static struct platform_driver sirf_audio_codec_driver = { - .driver = { - .name = "sirf-audio-codec", - .of_match_table = sirf_audio_codec_of_match, - .pm = &sirf_audio_codec_pm_ops, - }, - .probe = sirf_audio_codec_driver_probe, - .remove = sirf_audio_codec_driver_remove, -}; - -module_platform_driver(sirf_audio_codec_driver); - -module_description("sirf audio codec driver"); -module_author("rongjun ying <rongjun.ying@csr.com>"); -module_license("gpl v2"); diff --git a/sound/soc/sirf/kconfig b/sound/soc/sirf/kconfig --- a/sound/soc/sirf/kconfig +++ /dev/null -# spdx-license-identifier: gpl-2.0-only -config snd_soc_sirf - tristate "soc audio for the sirf soc chips" - depends on arch_sirf || compile_test - select snd_soc_generic_dmaengine_pcm - -config snd_soc_sirf_audio - tristate "soc audio support for sirf internal audio codec" - depends on snd_soc_sirf - select snd_soc_sirf_audio_codec - select snd_soc_sirf_audio_port - -config snd_soc_sirf_audio_port - select regmap_mmio - tristate - -config snd_soc_sirf_usp - tristate "soc audio (i2s protocol) for sirf soc usp interface" - depends on snd_soc_sirf - select regmap_mmio - tristate diff --git a/sound/soc/sirf/makefile b/sound/soc/sirf/makefile --- a/sound/soc/sirf/makefile +++ /dev/null -# spdx-license-identifier: gpl-2.0 -snd-soc-sirf-audio-objs := sirf-audio.o -snd-soc-sirf-audio-port-objs := sirf-audio-port.o -snd-soc-sirf-usp-objs := sirf-usp.o - -obj-$(config_snd_soc_sirf_audio) += snd-soc-sirf-audio.o -obj-$(config_snd_soc_sirf_audio_port) += snd-soc-sirf-audio-port.o -obj-$(config_snd_soc_sirf_usp) += snd-soc-sirf-usp.o diff --git a/sound/soc/sirf/sirf-audio-port.c b/sound/soc/sirf/sirf-audio-port.c --- a/sound/soc/sirf/sirf-audio-port.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-or-later -/* - * sirf audio port driver - * - * copyright (c) 2011 cambridge silicon radio limited, a csr plc group company. - */ -#include <linux/module.h> -#include <sound/soc.h> -#include <sound/dmaengine_pcm.h> - -struct sirf_audio_port { - struct regmap *regmap; - struct snd_dmaengine_dai_dma_data playback_dma_data; - struct snd_dmaengine_dai_dma_data capture_dma_data; -}; - - -static int sirf_audio_port_dai_probe(struct snd_soc_dai *dai) -{ - struct sirf_audio_port *port = snd_soc_dai_get_drvdata(dai); - - snd_soc_dai_init_dma_data(dai, &port->playback_dma_data, - &port->capture_dma_data); - return 0; -} - -static struct snd_soc_dai_driver sirf_audio_port_dai = { - .probe = sirf_audio_port_dai_probe, - .name = "sirf-audio-port", - .id = 0, - .playback = { - .channels_min = 2, - .channels_max = 2, - .rates = sndrv_pcm_rate_48000, - .formats = sndrv_pcm_fmtbit_s16_le, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = sndrv_pcm_rate_48000, - .formats = sndrv_pcm_fmtbit_s16_le, - }, -}; - -static const struct snd_soc_component_driver sirf_audio_port_component = { - .name = "sirf-audio-port", -}; - -static int sirf_audio_port_probe(struct platform_device *pdev) -{ - int ret; - struct sirf_audio_port *port; - - port = devm_kzalloc(&pdev->dev, - sizeof(struct sirf_audio_port), gfp_kernel); - if (!port) - return -enomem; - - ret = devm_snd_soc_register_component(&pdev->dev, - &sirf_audio_port_component, &sirf_audio_port_dai, 1); - if (ret) - return ret; - - platform_set_drvdata(pdev, port); - return devm_snd_dmaengine_pcm_register(&pdev->dev, null, 0); -} - -static const struct of_device_id sirf_audio_port_of_match[] = { - { .compatible = "sirf,audio-port", }, - {} -}; -module_device_table(of, sirf_audio_port_of_match); - -static struct platform_driver sirf_audio_port_driver = { - .driver = { - .name = "sirf-audio-port", - .of_match_table = sirf_audio_port_of_match, - }, - .probe = sirf_audio_port_probe, -}; - -module_platform_driver(sirf_audio_port_driver); - -module_description("sirf audio port driver"); -module_author("rongjun ying <rongjun.ying@csr.com>"); -module_license("gpl v2"); diff --git a/sound/soc/sirf/sirf-audio.c b/sound/soc/sirf/sirf-audio.c --- a/sound/soc/sirf/sirf-audio.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-or-later -/* - * sirf audio card driver - * - * copyright (c) 2011 cambridge silicon radio limited, a csr plc group company. - */ - -#include <linux/platform_device.h> -#include <linux/module.h> -#include <linux/of.h> -#include <linux/gpio.h> -#include <linux/of_gpio.h> -#include <sound/core.h> -#include <sound/pcm.h> -#include <sound/soc.h> - -struct sirf_audio_card { - unsigned int gpio_hp_pa; - unsigned int gpio_spk_pa; -}; - -static int sirf_audio_hp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *ctrl, int event) -{ - struct snd_soc_dapm_context *dapm = w->dapm; - struct snd_soc_card *card = dapm->card; - struct sirf_audio_card *sirf_audio_card = snd_soc_card_get_drvdata(card); - int on = !snd_soc_dapm_event_off(event); - - if (gpio_is_valid(sirf_audio_card->gpio_hp_pa)) - gpio_set_value(sirf_audio_card->gpio_hp_pa, on); - return 0; -} - -static int sirf_audio_spk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *ctrl, int event) -{ - struct snd_soc_dapm_context *dapm = w->dapm; - struct snd_soc_card *card = dapm->card; - struct sirf_audio_card *sirf_audio_card = snd_soc_card_get_drvdata(card); - int on = !snd_soc_dapm_event_off(event); - - if (gpio_is_valid(sirf_audio_card->gpio_spk_pa)) - gpio_set_value(sirf_audio_card->gpio_spk_pa, on); - - return 0; -} -static const struct snd_soc_dapm_widget sirf_audio_dapm_widgets[] = { - snd_soc_dapm_hp("hp", sirf_audio_hp_event), - snd_soc_dapm_spk("ext spk", sirf_audio_spk_event), - snd_soc_dapm_mic("ext mic", null), -}; - -static const struct snd_soc_dapm_route intercon[] = { - {"hp", null, "hpoutl"}, - {"hp", null, "hpoutr"}, - {"ext spk", null, "spkout"}, - {"micin1", null, "mic bias"}, - {"mic bias", null, "ext mic"}, -}; - -/* digital audio interface glue - connects codec <--> cpu */ -snd_soc_dailink_defs(sirf, - dailink_comp_array(comp_empty()), - dailink_comp_array(comp_codec(null, "sirf-audio-codec")), - dailink_comp_array(comp_empty())); - -static struct snd_soc_dai_link sirf_audio_dai_link[] = { - { - .name = "sirf audio card", - .stream_name = "sirf audio hifi", - snd_soc_dailink_reg(sirf), - }, -}; - -/* audio machine driver */ -static struct snd_soc_card snd_soc_sirf_audio_card = { - .name = "sirf audio card", - .owner = this_module, - .dai_link = sirf_audio_dai_link, - .num_links = array_size(sirf_audio_dai_link), - .dapm_widgets = sirf_audio_dapm_widgets, - .num_dapm_widgets = array_size(sirf_audio_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = array_size(intercon), -}; - -static int sirf_audio_probe(struct platform_device *pdev) -{ - struct snd_soc_card *card = &snd_soc_sirf_audio_card; - struct sirf_audio_card *sirf_audio_card; - int ret; - - sirf_audio_card = devm_kzalloc(&pdev->dev, sizeof(struct sirf_audio_card), - gfp_kernel); - if (sirf_audio_card == null) - return -enomem; - - sirf_audio_dai_link[0].cpus->of_node = - of_parse_phandle(pdev->dev.of_node, "sirf,audio-platform", 0); - sirf_audio_dai_link[0].platforms->of_node = - of_parse_phandle(pdev->dev.of_node, "sirf,audio-platform", 0); - sirf_audio_dai_link[0].codecs->of_node = - of_parse_phandle(pdev->dev.of_node, "sirf,audio-codec", 0); - sirf_audio_card->gpio_spk_pa = of_get_named_gpio(pdev->dev.of_node, - "spk-pa-gpios", 0); - sirf_audio_card->gpio_hp_pa = of_get_named_gpio(pdev->dev.of_node, - "hp-pa-gpios", 0); - if (gpio_is_valid(sirf_audio_card->gpio_spk_pa)) { - ret = devm_gpio_request_one(&pdev->dev, - sirf_audio_card->gpio_spk_pa, - gpiof_out_init_low, "spa_pa_sd"); - if (ret) { - dev_err(&pdev->dev, - "failed to request gpio_%d for reset: %d ", - sirf_audio_card->gpio_spk_pa, ret); - return ret; - } - } - if (gpio_is_valid(sirf_audio_card->gpio_hp_pa)) { - ret = devm_gpio_request_one(&pdev->dev, - sirf_audio_card->gpio_hp_pa, - gpiof_out_init_low, "hp_pa_sd"); - if (ret) { - dev_err(&pdev->dev, - "failed to request gpio_%d for reset: %d ", - sirf_audio_card->gpio_hp_pa, ret); - return ret; - } - } - - card->dev = &pdev->dev; - snd_soc_card_set_drvdata(card, sirf_audio_card); - - ret = devm_snd_soc_register_card(&pdev->dev, card); - if (ret) - dev_err(&pdev->dev, "snd_soc_register_card() failed:%d ", ret); - - return ret; -} - -static const struct of_device_id sirf_audio_of_match[] = { - {.compatible = "sirf,sirf-audio-card", }, - { }, -}; -module_device_table(of, sirf_audio_of_match); - -static struct platform_driver sirf_audio_driver = { - .driver = { - .name = "sirf-audio-card", - .pm = &snd_soc_pm_ops, - .of_match_table = sirf_audio_of_match, - }, - .probe = sirf_audio_probe, -}; -module_platform_driver(sirf_audio_driver); - -module_author("rongjun ying <rongjun.ying@csr.com>"); -module_description("alsa soc sirf audio card driver"); -module_license("gpl v2"); diff --git a/sound/soc/sirf/sirf-usp.c b/sound/soc/sirf/sirf-usp.c --- a/sound/soc/sirf/sirf-usp.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-or-later -/* - * sirf usp in i2s/dsp mode - * - * copyright (c) 2011 cambridge silicon radio limited, a csr plc group company. - */ -#include <linux/module.h> -#include <linux/io.h> -#include <linux/of.h> -#include <linux/clk.h> -#include <linux/pm_runtime.h> -#include <sound/soc.h> -#include <sound/pcm_params.h> -#include <sound/dmaengine_pcm.h> - -#include "sirf-usp.h" - -struct sirf_usp { - struct regmap *regmap; - struct clk *clk; - u32 mode1_reg; - u32 mode2_reg; - int daifmt_format; - struct snd_dmaengine_dai_dma_data playback_dma_data; - struct snd_dmaengine_dai_dma_data capture_dma_data; -}; - -static void sirf_usp_tx_enable(struct sirf_usp *usp) -{ - regmap_update_bits(usp->regmap, usp_tx_fifo_op, - usp_tx_fifo_reset, usp_tx_fifo_reset); - regmap_write(usp->regmap, usp_tx_fifo_op, 0); - - regmap_update_bits(usp->regmap, usp_tx_fifo_op, - usp_tx_fifo_start, usp_tx_fifo_start); - - regmap_update_bits(usp->regmap, usp_tx_rx_enable, - usp_tx_ena, usp_tx_ena); -} - -static void sirf_usp_tx_disable(struct sirf_usp *usp) -{ - regmap_update_bits(usp->regmap, usp_tx_rx_enable, - usp_tx_ena, ~usp_tx_ena); - /* fifo stop */ - regmap_write(usp->regmap, usp_tx_fifo_op, 0); -} - -static void sirf_usp_rx_enable(struct sirf_usp *usp) -{ - regmap_update_bits(usp->regmap, usp_rx_fifo_op, - usp_rx_fifo_reset, usp_rx_fifo_reset); - regmap_write(usp->regmap, usp_rx_fifo_op, 0); - - regmap_update_bits(usp->regmap, usp_rx_fifo_op, - usp_rx_fifo_start, usp_rx_fifo_start); - - regmap_update_bits(usp->regmap, usp_tx_rx_enable, - usp_rx_ena, usp_rx_ena); -} - -static void sirf_usp_rx_disable(struct sirf_usp *usp) -{ - regmap_update_bits(usp->regmap, usp_tx_rx_enable, - usp_rx_ena, ~usp_rx_ena); - /* fifo stop */ - regmap_write(usp->regmap, usp_rx_fifo_op, 0); -} - -static int sirf_usp_pcm_dai_probe(struct snd_soc_dai *dai) -{ - struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); - - snd_soc_dai_init_dma_data(dai, &usp->playback_dma_data, - &usp->capture_dma_data); - return 0; -} - -static int sirf_usp_pcm_set_dai_fmt(struct snd_soc_dai *dai, - unsigned int fmt) -{ - struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); - - /* set master/slave audio interface */ - switch (fmt & snd_soc_daifmt_master_mask) { - case snd_soc_daifmt_cbm_cfm: - break; - default: - dev_err(dai->dev, "only cbm and cfm supported "); - return -einval; - } - - switch (fmt & snd_soc_daifmt_format_mask) { - case snd_soc_daifmt_i2s: - case snd_soc_daifmt_dsp_a: - usp->daifmt_format = (fmt & snd_soc_daifmt_format_mask); - break; - default: - dev_err(dai->dev, "only i2s and dsp_a format supported "); - return -einval; - } - - switch (fmt & snd_soc_daifmt_inv_mask) { - case snd_soc_daifmt_nb_nf: - break; - case snd_soc_daifmt_ib_nf: - usp->daifmt_format |= (fmt & snd_soc_daifmt_inv_mask); - break; - default: - return -einval; - } - - return 0; -} - -static void sirf_usp_i2s_init(struct sirf_usp *usp) -{ - /* configure risc mode */ - regmap_update_bits(usp->regmap, usp_risc_dsp_mode, - usp_risc_dsp_sel, ~usp_risc_dsp_sel); - - /* - * configure dma io length register - * set no limit, usp can receive data continuously until it is diabled - */ - regmap_write(usp->regmap, usp_tx_dma_io_len, 0); - regmap_write(usp->regmap, usp_rx_dma_io_len, 0); - - /* configure mode2 register */ - regmap_write(usp->regmap, usp_mode2, (1 << usp_rxd_delay_len_offset) | - (0 << usp_txd_delay_len_offset) | - usp_tfs_clk_slave_mode | usp_rfs_clk_slave_mode); - - /* configure mode1 register */ - regmap_write(usp->regmap, usp_mode1, - usp_sync_mode | usp_en | usp_txd_act_edge_falling | - usp_rfs_act_level_logic1 | usp_tfs_act_level_logic1 | - usp_tx_uflow_repeat_zero | usp_clock_mode_slave); - - /* configure rx dma io control register */ - regmap_write(usp->regmap, usp_rx_dma_io_ctrl, 0); - - /* congiure rx fifo control register */ - regmap_write(usp->regmap, usp_rx_fifo_ctrl, - (usp_rx_fifo_threshold << usp_rx_fifo_thd_offset) | - (usp_tx_rx_fifo_width_dword << usp_rx_fifo_width_offset)); - - /* congiure rx fifo level check register */ - regmap_write(usp->regmap, usp_rx_fifo_level_chk, - rx_fifo_sc(0x04) | rx_fifo_lc(0x0e) | rx_fifo_hc(0x1b)); - - /* configure tx dma io control register*/ - regmap_write(usp->regmap, usp_tx_dma_io_ctrl, 0); - - /* configure tx fifo control register */ - regmap_write(usp->regmap, usp_tx_fifo_ctrl, - (usp_tx_fifo_threshold << usp_tx_fifo_thd_offset) | - (usp_tx_rx_fifo_width_dword << usp_tx_fifo_width_offset)); - /* congiure tx fifo level check register */ - regmap_write(usp->regmap, usp_tx_fifo_level_chk, - tx_fifo_sc(0x1b) | tx_fifo_lc(0x0e) | tx_fifo_hc(0x04)); -} - -static int sirf_usp_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) -{ - struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); - u32 data_len, frame_len, shifter_len; - - switch (params_format(params)) { - case sndrv_pcm_format_s16_le: - data_len = 16; - frame_len = 16; - break; - case sndrv_pcm_format_s24_le: - data_len = 24; - frame_len = 32; - break; - case sndrv_pcm_format_s24_3le: - data_len = 24; - frame_len = 24; - break; - default: - dev_err(dai->dev, "format unsupported "); - return -einval; - } - - shifter_len = data_len; - - switch (usp->daifmt_format & snd_soc_daifmt_format_mask) { - case snd_soc_daifmt_i2s: - regmap_update_bits(usp->regmap, usp_rx_frame_ctrl, - usp_i2s_sync_chg, usp_i2s_sync_chg); - break; - case snd_soc_daifmt_dsp_a: - regmap_update_bits(usp->regmap, usp_rx_frame_ctrl, - usp_i2s_sync_chg, 0); - frame_len = data_len * params_channels(params); - data_len = frame_len; - break; - default: - dev_err(dai->dev, "only support i2s and dsp_a mode "); - return -einval; - } - - switch (usp->daifmt_format & snd_soc_daifmt_inv_mask) { - case snd_soc_daifmt_nb_nf: - break; - case snd_soc_daifmt_ib_nf: - regmap_update_bits(usp->regmap, usp_mode1, - usp_rxd_act_edge_falling | usp_txd_act_edge_falling, - usp_rxd_act_edge_falling); - break; - default: - return -einval; - } - - if (substream->stream == sndrv_pcm_stream_playback) - regmap_update_bits(usp->regmap, usp_tx_frame_ctrl, - usp_txc_data_len_mask | usp_txc_frame_len_mask - | usp_txc_shifter_len_mask | usp_txc_slave_clk_sample, - ((data_len - 1) << usp_txc_data_len_offset) - | ((frame_len - 1) << usp_txc_frame_len_offset) - | ((shifter_len - 1) << usp_txc_shifter_len_offset) - | usp_txc_slave_clk_sample); - else - regmap_update_bits(usp->regmap, usp_rx_frame_ctrl, - usp_rxc_data_len_mask | usp_rxc_frame_len_mask - | usp_rxc_shifter_len_mask | usp_single_sync_mode, - ((data_len - 1) << usp_rxc_data_len_offset) - | ((frame_len - 1) << usp_rxc_frame_len_offset) - | ((shifter_len - 1) << usp_rxc_shifter_len_offset) - | usp_single_sync_mode); - - return 0; -} - -static int sirf_usp_pcm_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); - - 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) - sirf_usp_tx_enable(usp); - else - sirf_usp_rx_enable(usp); - break; - case sndrv_pcm_trigger_stop: - case sndrv_pcm_trigger_suspend: - case sndrv_pcm_trigger_pause_push: - if (substream->stream == sndrv_pcm_stream_playback) - sirf_usp_tx_disable(usp); - else - sirf_usp_rx_disable(usp); - break; - } - - return 0; -} - -static const struct snd_soc_dai_ops sirf_usp_pcm_dai_ops = { - .trigger = sirf_usp_pcm_trigger, - .set_fmt = sirf_usp_pcm_set_dai_fmt, - .hw_params = sirf_usp_pcm_hw_params, -}; - -static struct snd_soc_dai_driver sirf_usp_pcm_dai = { - .probe = sirf_usp_pcm_dai_probe, - .name = "sirf-usp-pcm", - .id = 0, - .playback = { - .stream_name = "sirf usp pcm playback", - .channels_min = 1, - .channels_max = 2, - .rates = sndrv_pcm_rate_8000_192000, - .formats = sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s24_le | - sndrv_pcm_fmtbit_s24_3le, - }, - .capture = { - .stream_name = "sirf usp pcm capture", - .channels_min = 1, - .channels_max = 2, - .rates = sndrv_pcm_rate_8000_192000, - .formats = sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s24_le | - sndrv_pcm_fmtbit_s24_3le, - }, - .ops = &sirf_usp_pcm_dai_ops, -}; - -static int sirf_usp_pcm_runtime_suspend(struct device *dev) -{ - struct sirf_usp *usp = dev_get_drvdata(dev); - - clk_disable_unprepare(usp->clk); - return 0; -} - -static int sirf_usp_pcm_runtime_resume(struct device *dev) -{ - struct sirf_usp *usp = dev_get_drvdata(dev); - int ret; - - ret = clk_prepare_enable(usp->clk); - if (ret) { - dev_err(dev, "clk_enable failed: %d ", ret); - return ret; - } - sirf_usp_i2s_init(usp); - return 0; -} - -#ifdef config_pm_sleep -static int sirf_usp_pcm_suspend(struct device *dev) -{ - struct sirf_usp *usp = dev_get_drvdata(dev); - - if (!pm_runtime_status_suspended(dev)) { - regmap_read(usp->regmap, usp_mode1, &usp->mode1_reg); - regmap_read(usp->regmap, usp_mode2, &usp->mode2_reg); - sirf_usp_pcm_runtime_suspend(dev); - } - return 0; -} - -static int sirf_usp_pcm_resume(struct device *dev) -{ - struct sirf_usp *usp = dev_get_drvdata(dev); - int ret; - - if (!pm_runtime_status_suspended(dev)) { - ret = sirf_usp_pcm_runtime_resume(dev); - if (ret) - return ret; - regmap_write(usp->regmap, usp_mode1, usp->mode1_reg); - regmap_write(usp->regmap, usp_mode2, usp->mode2_reg); - } - return 0; -} -#endif - -static const struct snd_soc_component_driver sirf_usp_component = { - .name = "sirf-usp", -}; - -static const struct regmap_config sirf_usp_regmap_config = { - .reg_bits = 32, - .reg_stride = 4, - .val_bits = 32, - .max_register = usp_rx_fifo_data, - .cache_type = regcache_none, -}; - -static int sirf_usp_pcm_probe(struct platform_device *pdev) -{ - int ret; - struct sirf_usp *usp; - void __iomem *base; - - usp = devm_kzalloc(&pdev->dev, sizeof(struct sirf_usp), - gfp_kernel); - if (!usp) - return -enomem; - - platform_set_drvdata(pdev, usp); - - base = devm_platform_ioremap_resource(pdev, 0); - if (is_err(base)) - return ptr_err(base); - usp->regmap = devm_regmap_init_mmio(&pdev->dev, base, - &sirf_usp_regmap_config); - if (is_err(usp->regmap)) - return ptr_err(usp->regmap); - - usp->clk = devm_clk_get(&pdev->dev, null); - if (is_err(usp->clk)) { - dev_err(&pdev->dev, "get clock failed. "); - return ptr_err(usp->clk); - } - - pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) { - ret = sirf_usp_pcm_runtime_resume(&pdev->dev); - if (ret) - return ret; - } - - ret = devm_snd_soc_register_component(&pdev->dev, &sirf_usp_component, - &sirf_usp_pcm_dai, 1); - if (ret) { - dev_err(&pdev->dev, "register audio soc dai failed. "); - return ret; - } - return devm_snd_dmaengine_pcm_register(&pdev->dev, null, 0); -} - -static int sirf_usp_pcm_remove(struct platform_device *pdev) -{ - if (!pm_runtime_enabled(&pdev->dev)) - sirf_usp_pcm_runtime_suspend(&pdev->dev); - else - pm_runtime_disable(&pdev->dev); - return 0; -} - -static const struct of_device_id sirf_usp_pcm_of_match[] = { - { .compatible = "sirf,prima2-usp-pcm", }, - {} -}; -module_device_table(of, sirf_usp_pcm_of_match); - -static const struct dev_pm_ops sirf_usp_pcm_pm_ops = { - set_runtime_pm_ops(sirf_usp_pcm_runtime_suspend, - sirf_usp_pcm_runtime_resume, null) - set_system_sleep_pm_ops(sirf_usp_pcm_suspend, sirf_usp_pcm_resume) -}; - -static struct platform_driver sirf_usp_pcm_driver = { - .driver = { - .name = "sirf-usp-pcm", - .of_match_table = sirf_usp_pcm_of_match, - .pm = &sirf_usp_pcm_pm_ops, - }, - .probe = sirf_usp_pcm_probe, - .remove = sirf_usp_pcm_remove, -}; - -module_platform_driver(sirf_usp_pcm_driver); - -module_description("sirf soc usp pcm bus driver"); -module_author("rongjun ying <rongjun.ying@csr.com>"); -module_license("gpl v2"); diff --git a/sound/soc/sirf/sirf-usp.h b/sound/soc/sirf/sirf-usp.h --- a/sound/soc/sirf/sirf-usp.h +++ /dev/null -/* spdx-license-identifier: gpl-2.0-or-later */ -/* - * arch/arm/mach-prima2/include/mach/sirfsoc_usp.h - * - * copyright (c) 2011 cambridge silicon radio limited, a csr plc group company. - */ - -#ifndef _sirf_usp_h -#define _sirf_usp_h - -/* usp registers */ -#define usp_mode1 0x00 -#define usp_mode2 0x04 -#define usp_tx_frame_ctrl 0x08 -#define usp_rx_frame_ctrl 0x0c -#define usp_tx_rx_enable 0x10 -#define usp_int_enable 0x14 -#define usp_int_status 0x18 -#define usp_pin_io_data 0x1c -#define usp_risc_dsp_mode 0x20 -#define usp_aysnc_param_reg 0x24 -#define usp_irda_x_mode_div 0x28 -#define usp_sm_cfg 0x2c -#define usp_tx_dma_io_ctrl 0x100 -#define usp_tx_dma_io_len 0x104 -#define usp_tx_fifo_ctrl 0x108 -#define usp_tx_fifo_level_chk 0x10c -#define usp_tx_fifo_op 0x110 -#define usp_tx_fifo_status 0x114 -#define usp_tx_fifo_data 0x118 -#define usp_rx_dma_io_ctrl 0x120 -#define usp_rx_dma_io_len 0x124 -#define usp_rx_fifo_ctrl 0x128 -#define usp_rx_fifo_level_chk 0x12c -#define usp_rx_fifo_op 0x130 -#define usp_rx_fifo_status 0x134 -#define usp_rx_fifo_data 0x138 - -/* usp mode register-1 */ -#define usp_sync_mode 0x00000001 -#define usp_clock_mode_slave 0x00000002 -#define usp_loop_back_en 0x00000004 -#define usp_hpsir_en 0x00000008 -#define usp_endian_ctrl_lsbf 0x00000010 -#define usp_en 0x00000020 -#define usp_rxd_act_edge_falling 0x00000040 -#define usp_txd_act_edge_falling 0x00000080 -#define usp_rfs_act_level_logic1 0x00000100 -#define usp_tfs_act_level_logic1 0x00000200 -#define usp_sclk_idle_mode_toggle 0x00000400 -#define usp_sclk_idle_level_logic1 0x00000800 -#define usp_sclk_pin_mode_io 0x00001000 -#define usp_rfs_pin_mode_io 0x00002000 -#define usp_tfs_pin_mode_io 0x00004000 -#define usp_rxd_pin_mode_io 0x00008000 -#define usp_txd_pin_mode_io 0x00010000 -#define usp_sclk_io_mode_input 0x00020000 -#define usp_rfs_io_mode_input 0x00040000 -#define usp_tfs_io_mode_input 0x00080000 -#define usp_rxd_io_mode_input 0x00100000 -#define usp_txd_io_mode_input 0x00200000 -#define usp_irda_width_div_mask 0x3fc00000 -#define usp_irda_width_div_offset 0 -#define usp_irda_idle_level_high 0x40000000 -#define usp_tx_uflow_repeat_zero 0x80000000 -#define usp_tx_endian_mode 0x00000020 -#define usp_rx_endian_mode 0x00000020 - -/* usp mode register-2 */ -#define usp_rxd_delay_len_mask 0x000000ff -#define usp_rxd_delay_len_offset 0 - -#define usp_txd_delay_len_mask 0x0000ff00 -#define usp_txd_delay_len_offset 8 - -#define usp_ena_ctrl_mode 0x00010000 -#define usp_frame_ctrl_mode 0x00020000 -#define usp_tfs_source_mode 0x00040000 -#define usp_tfs_ms_mode 0x00080000 -#define usp_clk_divisor_mask 0x7fe00000 -#define usp_clk_divisor_offset 21 - -#define usp_tfs_clk_slave_mode (1<<20) -#define usp_rfs_clk_slave_mode (1<<19) - -#define usp_irda_data_width 0x80000000 - -/* usp transmit frame control register */ - -#define usp_txc_data_len_mask 0x000000ff -#define usp_txc_data_len_offset 0 - -#define usp_txc_sync_len_mask 0x0000ff00 -#define usp_txc_sync_len_offset 8 - -#define usp_txc_frame_len_mask 0x00ff0000 -#define usp_txc_frame_len_offset 16 - -#define usp_txc_shifter_len_mask 0x1f000000 -#define usp_txc_shifter_len_offset 24 - -#define usp_txc_slave_clk_sample 0x20000000 - -#define usp_txc_clk_divisor_mask 0xc0000000 -#define usp_txc_clk_divisor_offset 30 - -/* usp receive frame control register */ - -#define usp_rxc_data_len_mask 0x000000ff -#define usp_rxc_data_len_offset 0 - -#define usp_rxc_frame_len_mask 0x0000ff00 -#define usp_rxc_frame_len_offset 8 - -#define usp_rxc_shifter_len_mask 0x001f0000 -#define usp_rxc_shifter_len_offset 16 - -#define usp_start_edge_mode 0x00800000 -#define usp_i2s_sync_chg 0x00200000 - -#define usp_rxc_clk_divisor_mask 0x0f000000 -#define usp_rxc_clk_divisor_offset 24 -#define usp_single_sync_mode 0x00400000 - -/* tx - rx enable register */ - -#define usp_rx_ena 0x00000001 -#define usp_tx_ena 0x00000002 - -/* usp interrupt enable and status register */ -#define usp_rx_done_int 0x00000001 -#define usp_tx_done_int 0x00000002 -#define usp_rx_oflow_int 0x00000004 -#define usp_tx_uflow_int 0x00000008 -#define usp_rx_io_dma_int 0x00000010 -#define usp_tx_io_dma_int 0x00000020 -#define usp_rxfifo_full_int 0x00000040 -#define usp_txfifo_empty_int 0x00000080 -#define usp_rxfifo_thd_int 0x00000100 -#define usp_txfifo_thd_int 0x00000200 -#define usp_uart_frm_err_int 0x00000400 -#define usp_rx_timeout_int 0x00000800 -#define usp_tx_allout_int 0x00001000 -#define usp_rxd_break_int 0x00008000 - -/* all possible tx interruots */ -#define usp_tx_interrupt (usp_tx_done_int|usp_tx_uflow_int|\ - usp_tx_io_dma_int|\ - usp_txfifo_empty_int|\ - usp_txfifo_thd_int) -/* all possible rx interruots */ -#define usp_rx_interrupt (usp_rx_done_int|usp_rx_oflow_int|\ - usp_rx_io_dma_int|\ - usp_rxfifo_full_int|\ - usp_rxfifo_thd_int|\ - usp_rx_timeout_int) - -#define usp_int_all 0x1fff - -/* usp pin i/o data register */ - -#define usp_rfs_pin_value_mask 0x00000001 -#define usp_tfs_pin_value_mask 0x00000002 -#define usp_rxd_pin_value_mask 0x00000004 -#define usp_txd_pin_value_mask 0x00000008 -#define usp_sclk_pin_value_mask 0x00000010 - -/* usp risc/dsp mode register */ -#define usp_risc_dsp_sel 0x00000001 - -/* usp async parameter register*/ - -#define usp_async_timeout_mask 0x0000ffff -#define usp_async_timeout_offset 0 -#define usp_async_timeout(x) (((x)&usp_async_timeout_mask) \ - <<usp_async_timeout_offset) - -#define usp_async_div2_mask 0x003f0000 -#define usp_async_div2_offset 16 - -/* usp tx dma i/o mode register */ -#define usp_tx_mode_io 0x00000001 - -/* usp tx dma i/o length register */ -#define usp_tx_data_len_mask 0xffffffff -#define usp_tx_data_len_offset 0 - -/* usp tx fifo control register */ -#define usp_tx_fifo_width_mask 0x00000003 -#define usp_tx_fifo_width_offset 0 - -#define usp_tx_fifo_thd_mask 0x000001fc -#define usp_tx_fifo_thd_offset 2 - -/* usp tx fifo level check register */ -#define usp_tx_fifo_level_check_mask 0x1f -#define usp_tx_fifo_sc_offset 0 -#define usp_tx_fifo_lc_offset 10 -#define usp_tx_fifo_hc_offset 20 - -#define tx_fifo_sc(x) (((x) & usp_tx_fifo_level_check_mask) \ - << usp_tx_fifo_sc_offset) -#define tx_fifo_lc(x) (((x) & usp_tx_fifo_level_check_mask) \ - << usp_tx_fifo_lc_offset) -#define tx_fifo_hc(x) (((x) & usp_tx_fifo_level_check_mask) \ - << usp_tx_fifo_hc_offset) - -/* usp tx fifo operation register */ -#define usp_tx_fifo_reset 0x00000001 -#define usp_tx_fifo_start 0x00000002 - -/* usp tx fifo status register */ -#define usp_tx_fifo_level_mask 0x0000007f -#define usp_tx_fifo_level_offset 0 - -#define usp_tx_fifo_full 0x00000080 -#define usp_tx_fifo_empty 0x00000100 - -/* usp tx fifo data register */ -#define usp_tx_fifo_data_mask 0xffffffff -#define usp_tx_fifo_data_offset 0 - -/* usp rx dma i/o mode register */ -#define usp_rx_mode_io 0x00000001 -#define usp_rx_dma_flush 0x00000004 - -/* usp rx dma i/o length register */ -#define usp_rx_data_len_mask 0xffffffff -#define usp_rx_data_len_offset 0 - -/* usp rx fifo control register */ -#define usp_rx_fifo_width_mask 0x00000003 -#define usp_rx_fifo_width_offset 0 - -#define usp_rx_fifo_thd_mask 0x000001fc -#define usp_rx_fifo_thd_offset 2 - -/* usp rx fifo level check register */ - -#define usp_rx_fifo_level_check_mask 0x1f -#define usp_rx_fifo_sc_offset 0 -#define usp_rx_fifo_lc_offset 10 -#define usp_rx_fifo_hc_offset 20 - -#define rx_fifo_sc(x) (((x) & usp_rx_fifo_level_check_mask) \ - << usp_rx_fifo_sc_offset) -#define rx_fifo_lc(x) (((x) & usp_rx_fifo_level_check_mask) \ - << usp_rx_fifo_lc_offset) -#define rx_fifo_hc(x) (((x) & usp_rx_fifo_level_check_mask) \ - << usp_rx_fifo_hc_offset) - -/* usp rx fifo operation register */ -#define usp_rx_fifo_reset 0x00000001 -#define usp_rx_fifo_start 0x00000002 - -/* usp rx fifo status register */ - -#define usp_rx_fifo_level_mask 0x0000007f -#define usp_rx_fifo_level_offset 0 - -#define usp_rx_fifo_full 0x00000080 -#define usp_rx_fifo_empty 0x00000100 - -/* usp rx fifo data register */ - -#define usp_rx_fifo_data_mask 0xffffffff -#define usp_rx_fifo_data_offset 0 - -/* - * when rx thd irq occur, sender just disable tx empty irq, - * remaining data in tx fifo wil also be sent out. - */ -#define usp_fifo_size 128 -#define usp_tx_fifo_threshold (usp_fifo_size/2) -#define usp_rx_fifo_threshold (usp_fifo_size/2) - -/* fifo_width for the usp_tx_fifo_ctrl and usp_rx_fifo_ctrl registers */ -#define usp_fifo_width_byte 0x00 -#define usp_fifo_width_word 0x01 -#define usp_fifo_width_dword 0x02 - -#define usp_async_div2 16 - -#define usp_plugout_retry_cnt 2 - -#define usp_tx_rx_fifo_width_dword 2 - -#define sirf_usp_div_mclk 0 - -#define sirf_usp_i2s_tfs_sync 0 -#define sirf_usp_i2s_rfs_sync 1 -#endif
Audio
61fbeb5dcb3debb88d9f2eeed7e599b1ed7e3344
arnd bergmann barry song baohua kernel org
sound
soc
bindings, codecs, sirf, sound
asoc: remove zte zx drivers
the zte zx platform is getting removed, so this driver is no longer needed.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
remove zte zx drivers
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['asoc ']
['txt', 'kconfig', 'c', 'makefile']
13
0
1,834
--- diff --git a/documentation/devicetree/bindings/sound/zte,tdm.txt b/documentation/devicetree/bindings/sound/zte,tdm.txt --- a/documentation/devicetree/bindings/sound/zte,tdm.txt +++ /dev/null -zte tdm dai driver - -required properties: - -- compatible : should be one of the following. - * zte,zx296718-tdm -- reg : physical base address of the controller and length of memory mapped - region. -- clocks : pairs of phandle and specifier referencing the controller's clocks. -- clock-names: "wclk" for the wclk. - "pclk" for the pclk. --#clock-cells: should be 1. -- zte,tdm-dma-sysctrl : reference to the sysctrl controller controlling - the dma. includes: - phandle of sysctrl. - register offset in sysctrl for control dma. - mask of the register that be written to sysctrl. - -example: - - tdm: tdm@1487000 { - compatible = "zte,zx296718-tdm"; - reg = <0x01487000 0x1000>; - clocks = <&audiocrm audio_tdm_wclk>, <&audiocrm audio_tdm_pclk>; - clock-names = "wclk", "pclk"; - #clock-cells = <1>; - pinctrl-names = "default"; - pinctrl-0 = <&tdm_global_pin>; - zte,tdm-dma-sysctrl = <&sysctrl 0x10c 4>; - }; diff --git a/documentation/devicetree/bindings/sound/zte,zx-aud96p22.txt b/documentation/devicetree/bindings/sound/zte,zx-aud96p22.txt --- a/documentation/devicetree/bindings/sound/zte,zx-aud96p22.txt +++ /dev/null -zte zx aud96p22 audio codec - -required properties: - - compatible: must be "zte,zx-aud96p22" - - #sound-dai-cells: should be 0 - - reg: i2c bus slave address of aud96p22 - -example: - - i2c0: i2c@1486000 { - compatible = "zte,zx296718-i2c"; - reg = <0x01486000 0x1000>; - interrupts = <gic_spi 35 irq_type_level_high>; - #address-cells = <1>; - #size-cells = <0>; - clocks = <&audiocrm audio_i2c0_wclk>; - clock-frequency = <1600000>; - - aud96p22: codec@22 { - compatible = "zte,zx-aud96p22"; - #sound-dai-cells = <0>; - reg = <0x22>; - }; - }; diff --git a/documentation/devicetree/bindings/sound/zte,zx-i2s.txt b/documentation/devicetree/bindings/sound/zte,zx-i2s.txt --- a/documentation/devicetree/bindings/sound/zte,zx-i2s.txt +++ /dev/null -zte zx296702 i2s controller - -required properties: - - compatible : must be one of: - "zte,zx296718-i2s", "zte,zx296702-i2s" - "zte,zx296702-i2s" - - reg : must contain i2s core's registers location and length - - clocks : pairs of phandle and specifier referencing the controller's clocks. - - clock-names: "wclk" for the wclk, "pclk" for the pclk to the i2s interface. - - dmas: pairs of phandle and specifier for the dma channel that is used by - the core. the core expects two dma channels for transmit. - - dma-names : must be "tx" and "rx" - -for more details on the 'dma', 'dma-names', 'clock' and 'clock-names' properties -please check: - * resource-names.txt - * clock/clock-bindings.txt - * dma/dma.txt - -example: - i2s0: i2s@b005000 { - #sound-dai-cells = <0>; - compatible = "zte,zx296718-i2s", "zte,zx296702-i2s"; - reg = <0x0b005000 0x1000>; - clocks = <&audiocrm audio_i2s0_wclk>, <&audiocrm audio_i2s0_pclk>; - clock-names = "wclk", "pclk"; - interrupts = <gic_spi 22 irq_type_level_high>; - dmas = <&dma 5>, <&dma 6>; - dma-names = "tx", "rx"; - }; - - sound { - compatible = "simple-audio-card"; - simple-audio-card,name = "zx296702_snd"; - simple-audio-card,format = "left_j"; - simple-audio-card,bitclock-master = <&sndcodec>; - simple-audio-card,frame-master = <&sndcodec>; - sndcpu: simple-audio-card,cpu { - sound-dai = <&i2s0>; - }; - - sndcodec: simple-audio-card,codec { - sound-dai = <&acodec>; - }; - }; diff --git a/documentation/devicetree/bindings/sound/zte,zx-spdif.txt b/documentation/devicetree/bindings/sound/zte,zx-spdif.txt --- a/documentation/devicetree/bindings/sound/zte,zx-spdif.txt +++ /dev/null -zte zx296702 spdif controller - -required properties: - - compatible : must be "zte,zx296702-spdif" - - reg : must contain spdif core's registers location and length - - clocks : pairs of phandle and specifier referencing the controller's clocks. - - clock-names: "tx" for the clock to the spdif interface. - - dmas: pairs of phandle and specifier for the dma channel that is used by - the core. the core expects one dma channel for transmit. - - dma-names : must be "tx" - -for more details on the 'dma', 'dma-names', 'clock' and 'clock-names' properties -please check: - * resource-names.txt - * clock/clock-bindings.txt - * dma/dma.txt - -example: - spdif0: spdif0@b004000 { - compatible = "zte,zx296702-spdif"; - reg = <0x0b004000 0x1000>; - clocks = <&lsp0clk zx296702_spdif0_div>; - clock-names = "tx"; - interrupts = <gic_spi 21 irq_type_level_high>; - dmas = <&dma 4>; - dma-names = "tx"; - }; diff --git a/sound/soc/kconfig b/sound/soc/kconfig --- a/sound/soc/kconfig +++ b/sound/soc/kconfig -source "sound/soc/zte/kconfig" diff --git a/sound/soc/makefile b/sound/soc/makefile --- a/sound/soc/makefile +++ b/sound/soc/makefile -obj-$(config_snd_soc) += zte/ diff --git a/sound/soc/codecs/makefile b/sound/soc/codecs/makefile --- a/sound/soc/codecs/makefile +++ b/sound/soc/codecs/makefile -snd-soc-zx-aud96p22-objs := zx_aud96p22.o -obj-$(config_snd_soc_zx_aud96p22) += snd-soc-zx-aud96p22.o diff --git a/sound/soc/codecs/zx_aud96p22.c b/sound/soc/codecs/zx_aud96p22.c --- a/sound/soc/codecs/zx_aud96p22.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-only -/* - * copyright (c) 2017 sanechips technology co., ltd. - * copyright 2017 linaro ltd. - * - * author: baoyou xie <baoyou.xie@linaro.org> - */ - -#include <linux/gpio/consumer.h> -#include <linux/i2c.h> -#include <linux/module.h> -#include <linux/regmap.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> -#include <sound/soc.h> -#include <sound/soc-dai.h> -#include <sound/tlv.h> - -#define aud96p22_reset 0x00 -#define rst_dac_dpz bit(0) -#define rst_adc_dpz bit(1) -#define aud96p22_i2s1_config_0 0x03 -#define i2s1_ms_mode bit(3) -#define i2s1_mode_mask 0x7 -#define i2s1_mode_right_j 0x0 -#define i2s1_mode_i2s 0x1 -#define i2s1_mode_left_j 0x2 -#define aud96p22_pd_0 0x15 -#define aud96p22_pd_1 0x16 -#define aud96p22_pd_3 0x18 -#define aud96p22_pd_4 0x19 -#define aud96p22_mute_0 0x1d -#define aud96p22_mute_2 0x1f -#define aud96p22_mute_4 0x21 -#define aud96p22_recvol_0 0x24 -#define aud96p22_recvol_1 0x25 -#define aud96p22_pga1vol_0 0x26 -#define aud96p22_pga1vol_1 0x27 -#define aud96p22_lmvol_0 0x34 -#define aud96p22_lmvol_1 0x35 -#define aud96p22_hs1vol_0 0x38 -#define aud96p22_hs1vol_1 0x39 -#define aud96p22_pga1sel_0 0x47 -#define aud96p22_pga1sel_1 0x48 -#define aud96p22_ldr1sel_0 0x59 -#define aud96p22_ldr1sel_1 0x60 -#define aud96p22_ldr2sel_0 0x5d -#define aud96p22_reg_max 0xfb - -struct aud96p22_priv { - struct regmap *regmap; -}; - -static int aud96p22_adc_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 aud96p22_priv *priv = snd_soc_component_get_drvdata(component); - struct regmap *regmap = priv->regmap; - - if (event != snd_soc_dapm_post_pmu) - return -einval; - - /* assert/de-assert the bit to reset adc data path */ - regmap_update_bits(regmap, aud96p22_reset, rst_adc_dpz, 0); - regmap_update_bits(regmap, aud96p22_reset, rst_adc_dpz, rst_adc_dpz); - - return 0; -} - -static int aud96p22_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 aud96p22_priv *priv = snd_soc_component_get_drvdata(component); - struct regmap *regmap = priv->regmap; - - if (event != snd_soc_dapm_post_pmu) - return -einval; - - /* assert/de-assert the bit to reset dac data path */ - regmap_update_bits(regmap, aud96p22_reset, rst_dac_dpz, 0); - regmap_update_bits(regmap, aud96p22_reset, rst_dac_dpz, rst_dac_dpz); - - return 0; -} - -static const declare_tlv_db_scale(lm_tlv, -11550, 50, 0); -static const declare_tlv_db_scale(hs_tlv, -3900, 300, 0); -static const declare_tlv_db_scale(rec_tlv, -9550, 50, 0); -static const declare_tlv_db_scale(pga_tlv, -1800, 100, 0); - -static const struct snd_kcontrol_new aud96p22_snd_controls[] = { - /* volume control */ - soc_double_r_tlv("master playback volume", aud96p22_lmvol_0, - aud96p22_lmvol_1, 0, 0xff, 0, lm_tlv), - soc_double_r_tlv("headphone volume", aud96p22_hs1vol_0, - aud96p22_hs1vol_1, 0, 0xf, 0, hs_tlv), - soc_double_r_tlv("master capture volume", aud96p22_recvol_0, - aud96p22_recvol_1, 0, 0xff, 0, rec_tlv), - soc_double_r_tlv("analogue capture volume", aud96p22_pga1vol_0, - aud96p22_pga1vol_1, 0, 0x37, 0, pga_tlv), - - /* mute control */ - soc_double("master playback switch", aud96p22_mute_2, 0, 1, 1, 1), - soc_double("headphone switch", aud96p22_mute_2, 4, 5, 1, 1), - soc_double("line out switch", aud96p22_mute_4, 0, 1, 1, 1), - soc_double("speaker switch", aud96p22_mute_4, 2, 3, 1, 1), - soc_double("master capture switch", aud96p22_mute_0, 0, 1, 1, 1), - soc_double("analogue capture switch", aud96p22_mute_0, 2, 3, 1, 1), -}; - -/* input mux kcontrols */ -static const unsigned int ain_mux_values[] = { - 0, 1, 3, 4, 5, -}; - -static const char * const ainl_mux_texts[] = { - "ainl1 differential", - "ainl1 single-ended", - "ainl3 single-ended", - "ainl2 differential", - "ainl2 single-ended", -}; - -static const char * const ainr_mux_texts[] = { - "ainr1 differential", - "ainr1 single-ended", - "ainr3 single-ended", - "ainr2 differential", - "ainr2 single-ended", -}; - -static soc_value_enum_single_decl(ainl_mux_enum, aud96p22_pga1sel_0, - 0, 0x7, ainl_mux_texts, ain_mux_values); -static soc_value_enum_single_decl(ainr_mux_enum, aud96p22_pga1sel_1, - 0, 0x7, ainr_mux_texts, ain_mux_values); - -static const struct snd_kcontrol_new ainl_mux_kcontrol = - soc_dapm_enum("ainl mux", ainl_mux_enum); -static const struct snd_kcontrol_new ainr_mux_kcontrol = - soc_dapm_enum("ainr mux", ainr_mux_enum); - -/* output mixer kcontrols */ -static const struct snd_kcontrol_new ld1_left_kcontrols[] = { - soc_dapm_single("dacl ld1l switch", aud96p22_ldr1sel_0, 0, 1, 0), - soc_dapm_single("ainl ld1l switch", aud96p22_ldr1sel_0, 1, 1, 0), - soc_dapm_single("ainr ld1l switch", aud96p22_ldr1sel_0, 2, 1, 0), -}; - -static const struct snd_kcontrol_new ld1_right_kcontrols[] = { - soc_dapm_single("dacr ld1r switch", aud96p22_ldr1sel_1, 8, 1, 0), - soc_dapm_single("ainr ld1r switch", aud96p22_ldr1sel_1, 9, 1, 0), - soc_dapm_single("ainl ld1r switch", aud96p22_ldr1sel_1, 10, 1, 0), -}; - -static const struct snd_kcontrol_new ld2_kcontrols[] = { - soc_dapm_single("dacl ld2 switch", aud96p22_ldr2sel_0, 0, 1, 0), - soc_dapm_single("ainl ld2 switch", aud96p22_ldr2sel_0, 1, 1, 0), - soc_dapm_single("dacr ld2 switch", aud96p22_ldr2sel_0, 2, 1, 0), -}; - -static const struct snd_soc_dapm_widget aud96p22_dapm_widgets[] = { - /* overall power bit */ - snd_soc_dapm_supply("power", aud96p22_pd_0, 0, 0, null, 0), - - /* input pins */ - snd_soc_dapm_input("ainl1p"), - snd_soc_dapm_input("ainl2p"), - snd_soc_dapm_input("ainl3"), - snd_soc_dapm_input("ainl1n"), - snd_soc_dapm_input("ainl2n"), - snd_soc_dapm_input("ainr2n"), - snd_soc_dapm_input("ainr1n"), - snd_soc_dapm_input("ainr3"), - snd_soc_dapm_input("ainr2p"), - snd_soc_dapm_input("ainr1p"), - - /* input muxes */ - snd_soc_dapm_mux("ainlmux", aud96p22_pd_1, 2, 0, &ainl_mux_kcontrol), - snd_soc_dapm_mux("ainrmux", aud96p22_pd_1, 3, 0, &ainr_mux_kcontrol), - - /* adcs */ - snd_soc_dapm_adc_e("adcl", "capture left", aud96p22_pd_1, 0, 0, - aud96p22_adc_event, snd_soc_dapm_post_pmu), - snd_soc_dapm_adc_e("adcr", "capture right", aud96p22_pd_1, 1, 0, - aud96p22_adc_event, snd_soc_dapm_post_pmu), - - /* dacs */ - snd_soc_dapm_dac_e("dacl", "playback left", aud96p22_pd_3, 0, 0, - aud96p22_dac_event, snd_soc_dapm_post_pmu), - snd_soc_dapm_dac_e("dacr", "playback right", aud96p22_pd_3, 1, 0, - aud96p22_dac_event, snd_soc_dapm_post_pmu), - - /* output mixers */ - snd_soc_dapm_mixer("ld1l", aud96p22_pd_3, 6, 0, ld1_left_kcontrols, - array_size(ld1_left_kcontrols)), - snd_soc_dapm_mixer("ld1r", aud96p22_pd_3, 7, 0, ld1_right_kcontrols, - array_size(ld1_right_kcontrols)), - snd_soc_dapm_mixer("ld2", aud96p22_pd_4, 2, 0, ld2_kcontrols, - array_size(ld2_kcontrols)), - - /* headset power switch */ - snd_soc_dapm_supply("hs1l", aud96p22_pd_3, 4, 0, null, 0), - snd_soc_dapm_supply("hs1r", aud96p22_pd_3, 5, 0, null, 0), - - /* output pins */ - snd_soc_dapm_output("hsoutl"), - snd_soc_dapm_output("lineoutl"), - snd_soc_dapm_output("lineoutmp"), - snd_soc_dapm_output("lineoutmn"), - snd_soc_dapm_output("lineoutr"), - snd_soc_dapm_output("hsoutr"), -}; - -static const struct snd_soc_dapm_route aud96p22_dapm_routes[] = { - { "ainlmux", "ainl1 differential", "ainl1n" }, - { "ainlmux", "ainl1 single-ended", "ainl1p" }, - { "ainlmux", "ainl3 single-ended", "ainl3" }, - { "ainlmux", "ainl2 differential", "ainl2n" }, - { "ainlmux", "ainl2 single-ended", "ainl2p" }, - - { "ainrmux", "ainr1 differential", "ainr1n" }, - { "ainrmux", "ainr1 single-ended", "ainr1p" }, - { "ainrmux", "ainr3 single-ended", "ainr3" }, - { "ainrmux", "ainr2 differential", "ainr2n" }, - { "ainrmux", "ainr2 single-ended", "ainr2p" }, - - { "adcl", null, "ainlmux" }, - { "adcr", null, "ainrmux" }, - - { "adcl", null, "power" }, - { "adcr", null, "power" }, - { "dacl", null, "power" }, - { "dacr", null, "power" }, - - { "ld1l", "dacl ld1l switch", "dacl" }, - { "ld1l", "ainl ld1l switch", "ainlmux" }, - { "ld1l", "ainr ld1l switch", "ainrmux" }, - - { "ld1r", "dacr ld1r switch", "dacr" }, - { "ld1r", "ainr ld1r switch", "ainrmux" }, - { "ld1r", "ainl ld1r switch", "ainlmux" }, - - { "ld2", "dacl ld2 switch", "dacl" }, - { "ld2", "ainl ld2 switch", "ainlmux" }, - { "ld2", "dacr ld2 switch", "dacr" }, - - { "hsoutl", null, "ld1l" }, - { "hsoutr", null, "ld1r" }, - { "hsoutl", null, "hs1l" }, - { "hsoutr", null, "hs1r" }, - - { "lineoutl", null, "ld1l" }, - { "lineoutr", null, "ld1r" }, - - { "lineoutmp", null, "ld2" }, - { "lineoutmn", null, "ld2" }, -}; - -static const struct snd_soc_component_driver aud96p22_driver = { - .controls = aud96p22_snd_controls, - .num_controls = array_size(aud96p22_snd_controls), - .dapm_widgets = aud96p22_dapm_widgets, - .num_dapm_widgets = array_size(aud96p22_dapm_widgets), - .dapm_routes = aud96p22_dapm_routes, - .num_dapm_routes = array_size(aud96p22_dapm_routes), - .idle_bias_on = 1, - .use_pmdown_time = 1, - .endianness = 1, - .non_legacy_dai_naming = 1, -}; - -static int aud96p22_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) -{ - struct aud96p22_priv *priv = snd_soc_component_get_drvdata(dai->component); - struct regmap *regmap = priv->regmap; - unsigned int val; - - /* master/slave mode */ - switch (fmt & snd_soc_daifmt_master_mask) { - case snd_soc_daifmt_cbs_cfs: - val = 0; - break; - case snd_soc_daifmt_cbm_cfm: - val = i2s1_ms_mode; - break; - default: - return -einval; - } - - regmap_update_bits(regmap, aud96p22_i2s1_config_0, i2s1_ms_mode, val); - - /* audio format */ - switch (fmt & snd_soc_daifmt_format_mask) { - case snd_soc_daifmt_right_j: - val = i2s1_mode_right_j; - break; - case snd_soc_daifmt_i2s: - val = i2s1_mode_i2s; - break; - case snd_soc_daifmt_left_j: - val = i2s1_mode_left_j; - break; - default: - return -einval; - } - - regmap_update_bits(regmap, aud96p22_i2s1_config_0, i2s1_mode_mask, val); - - return 0; -} - -static const struct snd_soc_dai_ops aud96p22_dai_ops = { - .set_fmt = aud96p22_set_fmt, -}; - -#define aud96p22_rates sndrv_pcm_rate_8000_192000 -#define aud96p22_formats (\ - sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s18_3le | \ - sndrv_pcm_fmtbit_s20_3le | sndrv_pcm_fmtbit_s24_le) - -static struct snd_soc_dai_driver aud96p22_dai = { - .name = "aud96p22-dai", - .playback = { - .stream_name = "playback", - .channels_min = 1, - .channels_max = 2, - .rates = aud96p22_rates, - .formats = aud96p22_formats, - }, - .capture = { - .stream_name = "capture", - .channels_min = 1, - .channels_max = 2, - .rates = aud96p22_rates, - .formats = aud96p22_formats, - }, - .ops = &aud96p22_dai_ops, -}; - -static const struct regmap_config aud96p22_regmap = { - .reg_bits = 8, - .val_bits = 8, - .max_register = aud96p22_reg_max, - .cache_type = regcache_rbtree, -}; - -static int aud96p22_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct device *dev = &i2c->dev; - struct aud96p22_priv *priv; - int ret; - - priv = devm_kzalloc(dev, sizeof(*priv), gfp_kernel); - if (priv == null) - return -enomem; - - priv->regmap = devm_regmap_init_i2c(i2c, &aud96p22_regmap); - if (is_err(priv->regmap)) { - ret = ptr_err(priv->regmap); - dev_err(dev, "failed to init i2c regmap: %d ", ret); - return ret; - } - - i2c_set_clientdata(i2c, priv); - - ret = devm_snd_soc_register_component(dev, &aud96p22_driver, &aud96p22_dai, 1); - if (ret) { - dev_err(dev, "failed to register component: %d ", ret); - return ret; - } - - return 0; -} - -static int aud96p22_i2c_remove(struct i2c_client *i2c) -{ - return 0; -} - -static const struct of_device_id aud96p22_dt_ids[] = { - { .compatible = "zte,zx-aud96p22", }, - { } -}; -module_device_table(of, aud96p22_dt_ids); - -static struct i2c_driver aud96p22_i2c_driver = { - .driver = { - .name = "zx_aud96p22", - .of_match_table = aud96p22_dt_ids, - }, - .probe = aud96p22_i2c_probe, - .remove = aud96p22_i2c_remove, -}; -module_i2c_driver(aud96p22_i2c_driver); - -module_description("zte asoc aud96p22 codec driver"); -module_author("baoyou xie <baoyou.xie@linaro.org>"); -module_license("gpl v2"); diff --git a/sound/soc/zte/kconfig b/sound/soc/zte/kconfig --- a/sound/soc/zte/kconfig +++ /dev/null -# spdx-license-identifier: gpl-2.0-only -config zx_spdif - tristate "zte zx spdif driver support" - depends on arch_zx || compile_test - depends on common_clk - select snd_soc_generic_dmaengine_pcm - help - say y or m if you want to add support for codecs attached to the - zte zx spdif interface - -config zx_i2s - tristate "zte zx i2s driver support" - depends on arch_zx || compile_test - depends on common_clk - select snd_soc_generic_dmaengine_pcm - help - say y or m if you want to add support for codecs attached to the - zte zx i2s interface - -config zx_tdm - tristate "zte zx tdm driver support" - depends on common_clk - select snd_soc_generic_dmaengine_pcm - help - say y or m if you want to add support for codecs attached to the - zte zx tdm interface diff --git a/sound/soc/zte/makefile b/sound/soc/zte/makefile --- a/sound/soc/zte/makefile +++ /dev/null -# spdx-license-identifier: gpl-2.0-only -obj-$(config_zx_spdif) += zx-spdif.o -obj-$(config_zx_i2s) += zx-i2s.o -obj-$(config_zx_tdm) += zx-tdm.o diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c --- a/sound/soc/zte/zx-i2s.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-only -/* - * copyright (c) 2015 linaro - * - * author: jun nie <jun.nie@linaro.org> - */ - -#include <linux/clk.h> -#include <linux/device.h> -#include <linux/init.h> -#include <linux/io.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> -#include <sound/soc.h> -#include <sound/soc-dai.h> - -#include <sound/core.h> -#include <sound/dmaengine_pcm.h> -#include <sound/initval.h> - -#define zx_i2s_process_ctrl 0x04 -#define zx_i2s_timing_ctrl 0x08 -#define zx_i2s_fifo_ctrl 0x0c -#define zx_i2s_fifo_status 0x10 -#define zx_i2s_int_en 0x14 -#define zx_i2s_int_status 0x18 -#define zx_i2s_data 0x1c -#define zx_i2s_frame_cntr 0x20 - -#define i2s_deagult_fifo_thres (0x10) -#define i2s_max_fifo_thres (0x20) - -#define zx_i2s_process_tx_en (1 << 0) -#define zx_i2s_process_tx_dis (0 << 0) -#define zx_i2s_process_rx_en (1 << 1) -#define zx_i2s_process_rx_dis (0 << 1) -#define zx_i2s_process_i2s_en (1 << 2) -#define zx_i2s_process_i2s_dis (0 << 2) - -#define zx_i2s_timing_mast (1 << 0) -#define zx_i2s_timing_slave (0 << 0) -#define zx_i2s_timing_ms_mask (1 << 0) -#define zx_i2s_timing_loop (1 << 1) -#define zx_i2s_timing_nor (0 << 1) -#define zx_i2s_timing_loop_mask (1 << 1) -#define zx_i2s_timing_ptnr (1 << 2) -#define zx_i2s_timing_ntpr (0 << 2) -#define zx_i2s_timing_phase_mask (1 << 2) -#define zx_i2s_timing_tdm (1 << 3) -#define zx_i2s_timing_i2s (0 << 3) -#define zx_i2s_timing_timing_mask (1 << 3) -#define zx_i2s_timing_long_sync (1 << 4) -#define zx_i2s_timing_short_sync (0 << 4) -#define zx_i2s_timing_sync_mask (1 << 4) -#define zx_i2s_timing_teak_en (1 << 5) -#define zx_i2s_timing_teak_dis (0 << 5) -#define zx_i2s_timing_teak_mask (1 << 5) -#define zx_i2s_timing_std_i2s (0 << 6) -#define zx_i2s_timing_msb_justif (1 << 6) -#define zx_i2s_timing_lsb_justif (2 << 6) -#define zx_i2s_timing_align_mask (3 << 6) -#define zx_i2s_timing_chn_mask (7 << 8) -#define zx_i2s_timing_chn(x) ((x - 1) << 8) -#define zx_i2s_timing_lane_mask (3 << 11) -#define zx_i2s_timing_lane(x) ((x - 1) << 11) -#define zx_i2s_timing_tscfg_mask (7 << 13) -#define zx_i2s_timing_tscfg(x) (x << 13) -#define zx_i2s_timing_ts_width_mask (0x1f << 16) -#define zx_i2s_timing_ts_width(x) ((x - 1) << 16) -#define zx_i2s_timing_data_size_mask (0x1f << 21) -#define zx_i2s_timing_data_size(x) ((x - 1) << 21) -#define zx_i2s_timing_cfg_err_mask (1 << 31) - -#define zx_i2s_fifo_ctrl_tx_rst (1 << 0) -#define zx_i2s_fifo_ctrl_tx_rst_mask (1 << 0) -#define zx_i2s_fifo_ctrl_rx_rst (1 << 1) -#define zx_i2s_fifo_ctrl_rx_rst_mask (1 << 1) -#define zx_i2s_fifo_ctrl_tx_dma_en (1 << 4) -#define zx_i2s_fifo_ctrl_tx_dma_dis (0 << 4) -#define zx_i2s_fifo_ctrl_tx_dma_mask (1 << 4) -#define zx_i2s_fifo_ctrl_rx_dma_en (1 << 5) -#define zx_i2s_fifo_ctrl_rx_dma_dis (0 << 5) -#define zx_i2s_fifo_ctrl_rx_dma_mask (1 << 5) -#define zx_i2s_fifo_ctrl_tx_thres_mask (0x1f << 8) -#define zx_i2s_fifo_ctrl_rx_thres_mask (0x1f << 16) - -#define clk_rat (32 * 4) - -struct zx_i2s_info { - struct snd_dmaengine_dai_dma_data dma_playback; - struct snd_dmaengine_dai_dma_data dma_capture; - struct clk *dai_wclk; - struct clk *dai_pclk; - void __iomem *reg_base; - int master; - resource_size_t mapbase; -}; - -static void zx_i2s_tx_en(void __iomem *base, bool on) -{ - unsigned long val; - - val = readl_relaxed(base + zx_i2s_process_ctrl); - if (on) - val |= zx_i2s_process_tx_en | zx_i2s_process_i2s_en; - else - val &= ~(zx_i2s_process_tx_en | zx_i2s_process_i2s_en); - writel_relaxed(val, base + zx_i2s_process_ctrl); -} - -static void zx_i2s_rx_en(void __iomem *base, bool on) -{ - unsigned long val; - - val = readl_relaxed(base + zx_i2s_process_ctrl); - if (on) - val |= zx_i2s_process_rx_en | zx_i2s_process_i2s_en; - else - val &= ~(zx_i2s_process_rx_en | zx_i2s_process_i2s_en); - writel_relaxed(val, base + zx_i2s_process_ctrl); -} - -static void zx_i2s_tx_dma_en(void __iomem *base, bool on) -{ - unsigned long val; - - val = readl_relaxed(base + zx_i2s_fifo_ctrl); - val |= zx_i2s_fifo_ctrl_tx_rst | (i2s_deagult_fifo_thres << 8); - if (on) - val |= zx_i2s_fifo_ctrl_tx_dma_en; - else - val &= ~zx_i2s_fifo_ctrl_tx_dma_en; - writel_relaxed(val, base + zx_i2s_fifo_ctrl); -} - -static void zx_i2s_rx_dma_en(void __iomem *base, bool on) -{ - unsigned long val; - - val = readl_relaxed(base + zx_i2s_fifo_ctrl); - val |= zx_i2s_fifo_ctrl_rx_rst | (i2s_deagult_fifo_thres << 16); - if (on) - val |= zx_i2s_fifo_ctrl_rx_dma_en; - else - val &= ~zx_i2s_fifo_ctrl_rx_dma_en; - writel_relaxed(val, base + zx_i2s_fifo_ctrl); -} - -#define zx_i2s_rates \ - (sndrv_pcm_rate_8000 | sndrv_pcm_rate_11025 | sndrv_pcm_rate_16000 | \ - sndrv_pcm_rate_22050 | sndrv_pcm_rate_32000 | sndrv_pcm_rate_44100 | \ - sndrv_pcm_rate_48000 | sndrv_pcm_rate_88200 | sndrv_pcm_rate_96000| \ - sndrv_pcm_rate_176400 | sndrv_pcm_rate_192000) - -#define zx_i2s_fmtbit \ - (sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s24_le | \ - sndrv_pcm_fmtbit_s32_le) - -static int zx_i2s_dai_probe(struct snd_soc_dai *dai) -{ - struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); - - snd_soc_dai_set_drvdata(dai, zx_i2s); - zx_i2s->dma_playback.addr = zx_i2s->mapbase + zx_i2s_data; - zx_i2s->dma_playback.maxburst = 16; - zx_i2s->dma_capture.addr = zx_i2s->mapbase + zx_i2s_data; - zx_i2s->dma_capture.maxburst = 16; - snd_soc_dai_init_dma_data(dai, &zx_i2s->dma_playback, - &zx_i2s->dma_capture); - return 0; -} - -static int zx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) -{ - struct zx_i2s_info *i2s = snd_soc_dai_get_drvdata(cpu_dai); - unsigned long val; - - val = readl_relaxed(i2s->reg_base + zx_i2s_timing_ctrl); - val &= ~(zx_i2s_timing_timing_mask | zx_i2s_timing_align_mask | - zx_i2s_timing_teak_mask | zx_i2s_timing_sync_mask | - zx_i2s_timing_ms_mask); - - switch (fmt & snd_soc_daifmt_format_mask) { - case snd_soc_daifmt_i2s: - val |= (zx_i2s_timing_i2s | zx_i2s_timing_std_i2s); - break; - case snd_soc_daifmt_left_j: - val |= (zx_i2s_timing_i2s | zx_i2s_timing_msb_justif); - break; - case snd_soc_daifmt_right_j: - val |= (zx_i2s_timing_i2s | zx_i2s_timing_lsb_justif); - break; - default: - dev_err(cpu_dai->dev, "unknown i2s timing "); - return -einval; - } - - switch (fmt & snd_soc_daifmt_master_mask) { - case snd_soc_daifmt_cbm_cfm: - /* codec is master, and i2s is slave. */ - i2s->master = 0; - val |= zx_i2s_timing_slave; - break; - case snd_soc_daifmt_cbs_cfs: - /* codec is slave, and i2s is master. */ - i2s->master = 1; - val |= zx_i2s_timing_mast; - break; - default: - dev_err(cpu_dai->dev, "unknown master/slave format "); - return -einval; - } - - writel_relaxed(val, i2s->reg_base + zx_i2s_timing_ctrl); - return 0; -} - -static int zx_i2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *socdai) -{ - struct zx_i2s_info *i2s = snd_soc_dai_get_drvdata(socdai); - struct snd_dmaengine_dai_dma_data *dma_data; - unsigned int lane, ch_num, len, ret = 0; - unsigned int ts_width = 32; - unsigned long val; - unsigned long chn_cfg; - - dma_data = snd_soc_dai_get_dma_data(socdai, substream); - dma_data->addr_width = ts_width >> 3; - - val = readl_relaxed(i2s->reg_base + zx_i2s_timing_ctrl); - val &= ~(zx_i2s_timing_ts_width_mask | zx_i2s_timing_data_size_mask | - zx_i2s_timing_lane_mask | zx_i2s_timing_chn_mask | - zx_i2s_timing_tscfg_mask); - - switch (params_format(params)) { - case sndrv_pcm_format_s16_le: - len = 16; - break; - case sndrv_pcm_format_s24_le: - len = 24; - break; - case sndrv_pcm_format_s32_le: - len = 32; - break; - default: - dev_err(socdai->dev, "unknown data format "); - return -einval; - } - val |= zx_i2s_timing_ts_width(ts_width) | zx_i2s_timing_data_size(len); - - ch_num = params_channels(params); - switch (ch_num) { - case 1: - lane = 1; - chn_cfg = 2; - break; - case 2: - case 4: - case 6: - case 8: - lane = ch_num / 2; - chn_cfg = 3; - break; - default: - dev_err(socdai->dev, "not support channel num %d ", ch_num); - return -einval; - } - val |= zx_i2s_timing_lane(lane); - val |= zx_i2s_timing_tscfg(chn_cfg); - val |= zx_i2s_timing_chn(ch_num); - writel_relaxed(val, i2s->reg_base + zx_i2s_timing_ctrl); - - if (i2s->master) - ret = clk_set_rate(i2s->dai_wclk, - params_rate(params) * ch_num * clk_rat); - - return ret; -} - -static int zx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); - int capture = (substream->stream == sndrv_pcm_stream_capture); - int ret = 0; - - switch (cmd) { - case sndrv_pcm_trigger_start: - if (capture) - zx_i2s_rx_dma_en(zx_i2s->reg_base, true); - else - zx_i2s_tx_dma_en(zx_i2s->reg_base, true); - fallthrough; - case sndrv_pcm_trigger_resume: - case sndrv_pcm_trigger_pause_release: - if (capture) - zx_i2s_rx_en(zx_i2s->reg_base, true); - else - zx_i2s_tx_en(zx_i2s->reg_base, true); - break; - - case sndrv_pcm_trigger_stop: - if (capture) - zx_i2s_rx_dma_en(zx_i2s->reg_base, false); - else - zx_i2s_tx_dma_en(zx_i2s->reg_base, false); - fallthrough; - case sndrv_pcm_trigger_suspend: - case sndrv_pcm_trigger_pause_push: - if (capture) - zx_i2s_rx_en(zx_i2s->reg_base, false); - else - zx_i2s_tx_en(zx_i2s->reg_base, false); - break; - - default: - ret = -einval; - break; - } - - return ret; -} - -static int zx_i2s_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); - int ret; - - ret = clk_prepare_enable(zx_i2s->dai_wclk); - if (ret) - return ret; - - ret = clk_prepare_enable(zx_i2s->dai_pclk); - if (ret) { - clk_disable_unprepare(zx_i2s->dai_wclk); - return ret; - } - - return ret; -} - -static void zx_i2s_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); - - clk_disable_unprepare(zx_i2s->dai_wclk); - clk_disable_unprepare(zx_i2s->dai_pclk); -} - -static const struct snd_soc_dai_ops zx_i2s_dai_ops = { - .trigger = zx_i2s_trigger, - .hw_params = zx_i2s_hw_params, - .set_fmt = zx_i2s_set_fmt, - .startup = zx_i2s_startup, - .shutdown = zx_i2s_shutdown, -}; - -static const struct snd_soc_component_driver zx_i2s_component = { - .name = "zx-i2s", -}; - -static struct snd_soc_dai_driver zx_i2s_dai = { - .name = "zx-i2s-dai", - .id = 0, - .probe = zx_i2s_dai_probe, - .playback = { - .channels_min = 1, - .channels_max = 8, - .rates = zx_i2s_rates, - .formats = zx_i2s_fmtbit, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = zx_i2s_rates, - .formats = zx_i2s_fmtbit, - }, - .ops = &zx_i2s_dai_ops, -}; - -static int zx_i2s_probe(struct platform_device *pdev) -{ - struct resource *res; - struct zx_i2s_info *zx_i2s; - int ret; - - zx_i2s = devm_kzalloc(&pdev->dev, sizeof(*zx_i2s), gfp_kernel); - if (!zx_i2s) - return -enomem; - - zx_i2s->dai_wclk = devm_clk_get(&pdev->dev, "wclk"); - if (is_err(zx_i2s->dai_wclk)) { - dev_err(&pdev->dev, "fail to get wclk "); - return ptr_err(zx_i2s->dai_wclk); - } - - zx_i2s->dai_pclk = devm_clk_get(&pdev->dev, "pclk"); - if (is_err(zx_i2s->dai_pclk)) { - dev_err(&pdev->dev, "fail to get pclk "); - return ptr_err(zx_i2s->dai_pclk); - } - - res = platform_get_resource(pdev, ioresource_mem, 0); - zx_i2s->mapbase = res->start; - zx_i2s->reg_base = devm_ioremap_resource(&pdev->dev, res); - if (is_err(zx_i2s->reg_base)) { - dev_err(&pdev->dev, "ioremap failed! "); - return ptr_err(zx_i2s->reg_base); - } - - writel_relaxed(0, zx_i2s->reg_base + zx_i2s_fifo_ctrl); - platform_set_drvdata(pdev, zx_i2s); - - ret = devm_snd_soc_register_component(&pdev->dev, &zx_i2s_component, - &zx_i2s_dai, 1); - if (ret) { - dev_err(&pdev->dev, "register dai failed: %d ", ret); - return ret; - } - - ret = devm_snd_dmaengine_pcm_register(&pdev->dev, null, 0); - if (ret) - dev_err(&pdev->dev, "register platform pcm failed: %d ", ret); - - return ret; -} - -static const struct of_device_id zx_i2s_dt_ids[] = { - { .compatible = "zte,zx296702-i2s", }, - {} -}; -module_device_table(of, zx_i2s_dt_ids); - -static struct platform_driver i2s_driver = { - .probe = zx_i2s_probe, - .driver = { - .name = "zx-i2s", - .of_match_table = zx_i2s_dt_ids, - }, -}; - -module_platform_driver(i2s_driver); - -module_author("jun nie <jun.nie@linaro.org>"); -module_description("zte i2s soc dai"); -module_license("gpl"); diff --git a/sound/soc/zte/zx-spdif.c b/sound/soc/zte/zx-spdif.c --- a/sound/soc/zte/zx-spdif.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-only -/* - * copyright (c) 2015 linaro - * - * author: jun nie <jun.nie@linaro.org> - */ - -#include <linux/clk.h> -#include <linux/device.h> -#include <linux/dmaengine.h> -#include <linux/init.h> -#include <linux/io.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/of_address.h> -#include <sound/asoundef.h> -#include <sound/core.h> -#include <sound/dmaengine_pcm.h> -#include <sound/initval.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> -#include <sound/soc.h> -#include <sound/soc-dai.h> - -#define zx_ctrl 0x04 -#define zx_fifoctrl 0x08 -#define zx_int_status 0x10 -#define zx_int_mask 0x14 -#define zx_data 0x18 -#define zx_valid_bit 0x1c -#define zx_ch_sta_1 0x20 -#define zx_ch_sta_2 0x24 -#define zx_ch_sta_3 0x28 -#define zx_ch_sta_4 0x2c -#define zx_ch_sta_5 0x30 -#define zx_ch_sta_6 0x34 - -#define zx_ctrl_moda_16 (0 << 6) -#define zx_ctrl_moda_18 bit(6) -#define zx_ctrl_moda_20 (2 << 6) -#define zx_ctrl_moda_24 (3 << 6) -#define zx_ctrl_moda_mask (3 << 6) - -#define zx_ctrl_enb bit(4) -#define zx_ctrl_dnb (0 << 4) -#define zx_ctrl_enb_mask bit(4) - -#define zx_ctrl_tx_open bit(0) -#define zx_ctrl_tx_close (0 << 0) -#define zx_ctrl_tx_mask bit(0) - -#define zx_ctrl_open (zx_ctrl_tx_open | zx_ctrl_enb) -#define zx_ctrl_close (zx_ctrl_tx_close | zx_ctrl_dnb) - -#define zx_ctrl_double_track (0 << 8) -#define zx_ctrl_left_track bit(8) -#define zx_ctrl_right_track (2 << 8) -#define zx_ctrl_track_mask (3 << 8) - -#define zx_fifoctrl_txth_mask (0x1f << 8) -#define zx_fifoctrl_txth(x) (x << 8) -#define zx_fifoctrl_tx_dma_en bit(2) -#define zx_fifoctrl_tx_dma_dis (0 << 2) -#define zx_fifoctrl_tx_dma_en_mask bit(2) -#define zx_fifoctrl_tx_fifo_rst bit(0) -#define zx_fifoctrl_tx_fifo_rst_mask bit(0) - -#define zx_valid_double_track (0 << 0) -#define zx_valid_left_track bit(1) -#define zx_valid_right_track (2 << 0) -#define zx_valid_track_mask (3 << 0) - -#define zx_spdif_clk_rat (2 * 32) - -struct zx_spdif_info { - struct snd_dmaengine_dai_dma_data dma_data; - struct clk *dai_clk; - void __iomem *reg_base; - resource_size_t mapbase; -}; - -static int zx_spdif_dai_probe(struct snd_soc_dai *dai) -{ - struct zx_spdif_info *zx_spdif = dev_get_drvdata(dai->dev); - - snd_soc_dai_set_drvdata(dai, zx_spdif); - zx_spdif->dma_data.addr = zx_spdif->mapbase + zx_data; - zx_spdif->dma_data.maxburst = 8; - snd_soc_dai_init_dma_data(dai, &zx_spdif->dma_data, null); - return 0; -} - -static int zx_spdif_chanstats(void __iomem *base, unsigned int rate) -{ - u32 cstas1; - - switch (rate) { - case 22050: - cstas1 = iec958_aes3_con_fs_22050; - break; - case 24000: - cstas1 = iec958_aes3_con_fs_24000; - break; - case 32000: - cstas1 = iec958_aes3_con_fs_32000; - break; - case 44100: - cstas1 = iec958_aes3_con_fs_44100; - break; - case 48000: - cstas1 = iec958_aes3_con_fs_48000; - break; - case 88200: - cstas1 = iec958_aes3_con_fs_88200; - break; - case 96000: - cstas1 = iec958_aes3_con_fs_96000; - break; - case 176400: - cstas1 = iec958_aes3_con_fs_176400; - break; - case 192000: - cstas1 = iec958_aes3_con_fs_192000; - break; - default: - return -einval; - } - cstas1 = cstas1 << 24; - cstas1 |= iec958_aes0_con_not_copyright; - - writel_relaxed(cstas1, base + zx_ch_sta_1); - return 0; -} - -static int zx_spdif_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *socdai) -{ - struct zx_spdif_info *zx_spdif = dev_get_drvdata(socdai->dev); - struct zx_spdif_info *spdif = snd_soc_dai_get_drvdata(socdai); - struct snd_dmaengine_dai_dma_data *dma_data = - snd_soc_dai_get_dma_data(socdai, substream); - u32 val, ch_num, rate; - int ret; - - dma_data->addr_width = params_width(params) >> 3; - - val = readl_relaxed(zx_spdif->reg_base + zx_ctrl); - val &= ~zx_ctrl_moda_mask; - switch (params_format(params)) { - case sndrv_pcm_format_s16_le: - val |= zx_ctrl_moda_16; - break; - - case sndrv_pcm_format_s18_3le: - val |= zx_ctrl_moda_18; - break; - - case sndrv_pcm_format_s20_3le: - val |= zx_ctrl_moda_20; - break; - - case sndrv_pcm_format_s24_le: - val |= zx_ctrl_moda_24; - break; - default: - dev_err(socdai->dev, "format not support! "); - return -einval; - } - - ch_num = params_channels(params); - if (ch_num == 2) - val |= zx_ctrl_double_track; - else - val |= zx_ctrl_left_track; - writel_relaxed(val, zx_spdif->reg_base + zx_ctrl); - - val = readl_relaxed(zx_spdif->reg_base + zx_valid_bit); - val &= ~zx_valid_track_mask; - if (ch_num == 2) - val |= zx_valid_double_track; - else - val |= zx_valid_right_track; - writel_relaxed(val, zx_spdif->reg_base + zx_valid_bit); - - rate = params_rate(params); - ret = zx_spdif_chanstats(zx_spdif->reg_base, rate); - if (ret) - return ret; - return clk_set_rate(spdif->dai_clk, rate * ch_num * zx_spdif_clk_rat); -} - -static void zx_spdif_cfg_tx(void __iomem *base, int on) -{ - u32 val; - - val = readl_relaxed(base + zx_ctrl); - val &= ~(zx_ctrl_enb_mask | zx_ctrl_tx_mask); - val |= on ? zx_ctrl_open : zx_ctrl_close; - writel_relaxed(val, base + zx_ctrl); - - val = readl_relaxed(base + zx_fifoctrl); - val &= ~zx_fifoctrl_tx_dma_en_mask; - if (on) - val |= zx_fifoctrl_tx_dma_en; - writel_relaxed(val, base + zx_fifoctrl); -} - -static int zx_spdif_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - u32 val; - struct zx_spdif_info *zx_spdif = dev_get_drvdata(dai->dev); - int ret = 0; - - switch (cmd) { - case sndrv_pcm_trigger_start: - val = readl_relaxed(zx_spdif->reg_base + zx_fifoctrl); - val |= zx_fifoctrl_tx_fifo_rst; - writel_relaxed(val, zx_spdif->reg_base + zx_fifoctrl); - fallthrough; - case sndrv_pcm_trigger_resume: - case sndrv_pcm_trigger_pause_release: - zx_spdif_cfg_tx(zx_spdif->reg_base, true); - break; - - case sndrv_pcm_trigger_stop: - case sndrv_pcm_trigger_suspend: - case sndrv_pcm_trigger_pause_push: - zx_spdif_cfg_tx(zx_spdif->reg_base, false); - break; - - default: - ret = -einval; - break; - } - - return ret; -} - -static int zx_spdif_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct zx_spdif_info *zx_spdif = dev_get_drvdata(dai->dev); - - return clk_prepare_enable(zx_spdif->dai_clk); -} - -static void zx_spdif_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct zx_spdif_info *zx_spdif = dev_get_drvdata(dai->dev); - - clk_disable_unprepare(zx_spdif->dai_clk); -} - -#define zx_rates \ - (sndrv_pcm_rate_22050 | sndrv_pcm_rate_32000 | sndrv_pcm_rate_44100 | \ - sndrv_pcm_rate_48000 | sndrv_pcm_rate_88200 | sndrv_pcm_rate_96000 |\ - sndrv_pcm_rate_176400 | sndrv_pcm_rate_192000) - -#define zx_format \ - (sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_s18_3le \ - | sndrv_pcm_fmtbit_s20_3le | sndrv_pcm_fmtbit_s24_le) - -static const struct snd_soc_dai_ops zx_spdif_dai_ops = { - .trigger = zx_spdif_trigger, - .startup = zx_spdif_startup, - .shutdown = zx_spdif_shutdown, - .hw_params = zx_spdif_hw_params, -}; - -static struct snd_soc_dai_driver zx_spdif_dai = { - .name = "spdif", - .id = 0, - .probe = zx_spdif_dai_probe, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = zx_rates, - .formats = zx_format, - }, - .ops = &zx_spdif_dai_ops, -}; - -static const struct snd_soc_component_driver zx_spdif_component = { - .name = "spdif", -}; - -static void zx_spdif_dev_init(void __iomem *base) -{ - u32 val; - - writel_relaxed(0, base + zx_ctrl); - writel_relaxed(0, base + zx_int_mask); - writel_relaxed(0xf, base + zx_int_status); - writel_relaxed(0x1, base + zx_fifoctrl); - - val = readl_relaxed(base + zx_fifoctrl); - val &= ~(zx_fifoctrl_txth_mask | zx_fifoctrl_tx_fifo_rst_mask); - val |= zx_fifoctrl_txth(8); - writel_relaxed(val, base + zx_fifoctrl); -} - -static int zx_spdif_probe(struct platform_device *pdev) -{ - struct resource *res; - struct zx_spdif_info *zx_spdif; - int ret; - - zx_spdif = devm_kzalloc(&pdev->dev, sizeof(*zx_spdif), gfp_kernel); - if (!zx_spdif) - return -enomem; - - zx_spdif->dai_clk = devm_clk_get(&pdev->dev, "tx"); - if (is_err(zx_spdif->dai_clk)) { - dev_err(&pdev->dev, "fail to get clk "); - return ptr_err(zx_spdif->dai_clk); - } - - res = platform_get_resource(pdev, ioresource_mem, 0); - zx_spdif->mapbase = res->start; - zx_spdif->reg_base = devm_ioremap_resource(&pdev->dev, res); - if (is_err(zx_spdif->reg_base)) { - return ptr_err(zx_spdif->reg_base); - } - - zx_spdif_dev_init(zx_spdif->reg_base); - platform_set_drvdata(pdev, zx_spdif); - - ret = devm_snd_soc_register_component(&pdev->dev, &zx_spdif_component, - &zx_spdif_dai, 1); - if (ret) { - dev_err(&pdev->dev, "register dai failed: %d ", ret); - return ret; - } - - ret = devm_snd_dmaengine_pcm_register(&pdev->dev, null, 0); - if (ret) - dev_err(&pdev->dev, "register platform pcm failed: %d ", ret); - - return ret; -} - -static const struct of_device_id zx_spdif_dt_ids[] = { - { .compatible = "zte,zx296702-spdif", }, - {} -}; -module_device_table(of, zx_spdif_dt_ids); - -static struct platform_driver spdif_driver = { - .probe = zx_spdif_probe, - .driver = { - .name = "zx-spdif", - .of_match_table = zx_spdif_dt_ids, - }, -}; - -module_platform_driver(spdif_driver); - -module_author("jun nie <jun.nie@linaro.org>"); -module_description("zte spdif soc dai"); -module_license("gpl"); diff --git a/sound/soc/zte/zx-tdm.c b/sound/soc/zte/zx-tdm.c --- a/sound/soc/zte/zx-tdm.c +++ /dev/null -// spdx-license-identifier: gpl-2.0-only -/* - * zte's tdm driver - * - * copyright (c) 2017 zte ltd - * - * author: baoyou xie <baoyou.xie@linaro.org> - */ - -#include <linux/clk.h> -#include <linux/io.h> -#include <linux/mfd/syscon.h> -#include <linux/module.h> -#include <sound/dmaengine_pcm.h> -#include <sound/pcm_params.h> -#include <sound/soc.h> -#include <sound/soc-dai.h> - -#define reg_timing_ctrl 0x04 -#define reg_tx_fifo_ctrl 0x0c -#define reg_rx_fifo_ctrl 0x10 -#define reg_int_en 0x1c -#define reg_int_status 0x20 -#define reg_databuf 0x24 -#define reg_ts_mask0 0x44 -#define reg_process_ctrl 0x54 - -#define fifo_ctrl_tx_rst bit(0) -#define fifo_ctrl_rx_rst bit(0) -#define deagult_fifo_thres genmask(4, 2) - -#define fifo_ctrl_tx_dma_en bit(1) -#define fifo_ctrl_rx_dma_en bit(1) - -#define tx_fifo_rst_mask bit(0) -#define rx_fifo_rst_mask bit(0) - -#define fifoctrl_tx_fifo_rst bit(0) -#define fifoctrl_rx_fifo_rst bit(0) - -#define txth_mask genmask(5, 2) -#define rxth_mask genmask(5, 2) - -#define fifoctrl_threshold(x) ((x) << 2) - -#define timing_ms_mask bit(1) -/* - * 00: 8 clk cycles every timeslot - * 01: 16 clk cycles every timeslot - * 10: 32 clk cycles every timeslot - */ -#define timing_sync_width_mask genmask(6, 5) -#define timing_width_shift 5 -#define timing_default_width 0 -#define timing_ts_width(x) ((x) << timing_width_shift) -#define timing_width_factor 8 - -#define timing_master_mode bit(21) -#define timing_lsb_first bit(20) -#define timing_ts_num(x) (((x) - 1) << 7) -#define timing_clk_sel_mask genmask(2, 0) -#define timing_clk_sel_def bit(2) - -#define process_tx_en bit(0) -#define process_rx_en bit(1) -#define process_tdm_en bit(2) -#define process_disable_all 0 - -#define int_disable_all 0 -#define int_status_mask genmask(6, 0) - -struct zx_tdm_info { - struct snd_dmaengine_dai_dma_data dma_playback; - struct snd_dmaengine_dai_dma_data dma_capture; - resource_size_t phy_addr; - void __iomem *regbase; - struct clk *dai_wclk; - struct clk *dai_pclk; - int master; - struct device *dev; -}; - -static inline u32 zx_tdm_readl(struct zx_tdm_info *tdm, u16 reg) -{ - return readl_relaxed(tdm->regbase + reg); -} - -static inline void zx_tdm_writel(struct zx_tdm_info *tdm, u16 reg, u32 val) -{ - writel_relaxed(val, tdm->regbase + reg); -} - -static void zx_tdm_tx_en(struct zx_tdm_info *tdm, bool on) -{ - unsigned long val; - - val = zx_tdm_readl(tdm, reg_process_ctrl); - if (on) - val |= process_tx_en | process_tdm_en; - else - val &= ~(process_tx_en | process_tdm_en); - zx_tdm_writel(tdm, reg_process_ctrl, val); -} - -static void zx_tdm_rx_en(struct zx_tdm_info *tdm, bool on) -{ - unsigned long val; - - val = zx_tdm_readl(tdm, reg_process_ctrl); - if (on) - val |= process_rx_en | process_tdm_en; - else - val &= ~(process_rx_en | process_tdm_en); - zx_tdm_writel(tdm, reg_process_ctrl, val); -} - -static void zx_tdm_tx_dma_en(struct zx_tdm_info *tdm, bool on) -{ - unsigned long val; - - val = zx_tdm_readl(tdm, reg_tx_fifo_ctrl); - val |= fifo_ctrl_tx_rst | deagult_fifo_thres; - if (on) - val |= fifo_ctrl_tx_dma_en; - else - val &= ~fifo_ctrl_tx_dma_en; - zx_tdm_writel(tdm, reg_tx_fifo_ctrl, val); -} - -static void zx_tdm_rx_dma_en(struct zx_tdm_info *tdm, bool on) -{ - unsigned long val; - - val = zx_tdm_readl(tdm, reg_rx_fifo_ctrl); - val |= fifo_ctrl_rx_rst | deagult_fifo_thres; - if (on) - val |= fifo_ctrl_rx_dma_en; - else - val &= ~fifo_ctrl_rx_dma_en; - zx_tdm_writel(tdm, reg_rx_fifo_ctrl, val); -} - -#define zx_tdm_rates (sndrv_pcm_rate_8000 | sndrv_pcm_rate_16000) - -#define zx_tdm_fmtbit \ - (sndrv_pcm_fmtbit_s16_le | sndrv_pcm_fmtbit_mu_law | \ - sndrv_pcm_fmtbit_a_law) - -static int zx_tdm_dai_probe(struct snd_soc_dai *dai) -{ - struct zx_tdm_info *zx_tdm = dev_get_drvdata(dai->dev); - - snd_soc_dai_set_drvdata(dai, zx_tdm); - zx_tdm->dma_playback.addr = zx_tdm->phy_addr + reg_databuf; - zx_tdm->dma_playback.maxburst = 16; - zx_tdm->dma_capture.addr = zx_tdm->phy_addr + reg_databuf; - zx_tdm->dma_capture.maxburst = 16; - snd_soc_dai_init_dma_data(dai, &zx_tdm->dma_playback, - &zx_tdm->dma_capture); - return 0; -} - -static int zx_tdm_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) -{ - struct zx_tdm_info *tdm = snd_soc_dai_get_drvdata(cpu_dai); - unsigned long val; - - val = zx_tdm_readl(tdm, reg_timing_ctrl); - val &= ~(timing_sync_width_mask | timing_ms_mask); - val |= timing_default_width << timing_width_shift; - - switch (fmt & snd_soc_daifmt_master_mask) { - case snd_soc_daifmt_cbm_cfm: - tdm->master = 1; - val |= timing_master_mode; - break; - case snd_soc_daifmt_cbs_cfs: - tdm->master = 0; - val &= ~timing_master_mode; - break; - default: - dev_err(cpu_dai->dev, "unknown master/slave format "); - return -einval; - } - - - zx_tdm_writel(tdm, reg_timing_ctrl, val); - - return 0; -} - -static int zx_tdm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *socdai) -{ - struct zx_tdm_info *tdm = snd_soc_dai_get_drvdata(socdai); - struct snd_dmaengine_dai_dma_data *dma_data; - unsigned int ts_width = timing_default_width; - unsigned int ch_num = 32; - unsigned int mask = 0; - unsigned int ret = 0; - unsigned long val; - - dma_data = snd_soc_dai_get_dma_data(socdai, substream); - dma_data->addr_width = ch_num >> 3; - - switch (params_format(params)) { - case sndrv_pcm_format_mu_law: - case sndrv_pcm_format_a_law: - case sndrv_pcm_format_s16_le: - ts_width = 1; - break; - default: - dev_err(socdai->dev, "unknown data format "); - return -einval; - } - - val = zx_tdm_readl(tdm, reg_timing_ctrl); - val |= timing_ts_width(ts_width) | timing_ts_num(1); - zx_tdm_writel(tdm, reg_timing_ctrl, val); - zx_tdm_writel(tdm, reg_ts_mask0, mask); - - if (tdm->master) - ret = clk_set_rate(tdm->dai_wclk, - params_rate(params) * timing_width_factor * ch_num); - - return ret; -} - -static int zx_tdm_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - int capture = (substream->stream == sndrv_pcm_stream_capture); - struct zx_tdm_info *zx_tdm = dev_get_drvdata(dai->dev); - unsigned int val; - int ret = 0; - - switch (cmd) { - case sndrv_pcm_trigger_start: - if (capture) { - val = zx_tdm_readl(zx_tdm, reg_rx_fifo_ctrl); - val |= fifoctrl_rx_fifo_rst; - zx_tdm_writel(zx_tdm, reg_rx_fifo_ctrl, val); - - zx_tdm_rx_dma_en(zx_tdm, true); - } else { - val = zx_tdm_readl(zx_tdm, reg_tx_fifo_ctrl); - val |= fifoctrl_tx_fifo_rst; - zx_tdm_writel(zx_tdm, reg_tx_fifo_ctrl, val); - - zx_tdm_tx_dma_en(zx_tdm, true); - } - break; - case sndrv_pcm_trigger_resume: - case sndrv_pcm_trigger_pause_release: - if (capture) - zx_tdm_rx_en(zx_tdm, true); - else - zx_tdm_tx_en(zx_tdm, true); - break; - case sndrv_pcm_trigger_stop: - if (capture) - zx_tdm_rx_dma_en(zx_tdm, false); - else - zx_tdm_tx_dma_en(zx_tdm, false); - break; - case sndrv_pcm_trigger_suspend: - case sndrv_pcm_trigger_pause_push: - if (capture) - zx_tdm_rx_en(zx_tdm, false); - else - zx_tdm_tx_en(zx_tdm, false); - break; - default: - ret = -einval; - break; - } - - return ret; -} - -static int zx_tdm_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct zx_tdm_info *zx_tdm = dev_get_drvdata(dai->dev); - int ret; - - ret = clk_prepare_enable(zx_tdm->dai_wclk); - if (ret) - return ret; - - ret = clk_prepare_enable(zx_tdm->dai_pclk); - if (ret) { - clk_disable_unprepare(zx_tdm->dai_wclk); - return ret; - } - - return 0; -} - -static void zx_tdm_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct zx_tdm_info *zx_tdm = dev_get_drvdata(dai->dev); - - clk_disable_unprepare(zx_tdm->dai_pclk); - clk_disable_unprepare(zx_tdm->dai_wclk); -} - -static const struct snd_soc_dai_ops zx_tdm_dai_ops = { - .trigger = zx_tdm_trigger, - .hw_params = zx_tdm_hw_params, - .set_fmt = zx_tdm_set_fmt, - .startup = zx_tdm_startup, - .shutdown = zx_tdm_shutdown, -}; - -static const struct snd_soc_component_driver zx_tdm_component = { - .name = "zx-tdm", -}; - -static void zx_tdm_init_state(struct zx_tdm_info *tdm) -{ - unsigned int val; - - zx_tdm_writel(tdm, reg_process_ctrl, process_disable_all); - - val = zx_tdm_readl(tdm, reg_timing_ctrl); - val |= timing_lsb_first; - val &= ~timing_clk_sel_mask; - val |= timing_clk_sel_def; - zx_tdm_writel(tdm, reg_timing_ctrl, val); - - zx_tdm_writel(tdm, reg_int_en, int_disable_all); - /* - * write int_status register to clear it. - */ - zx_tdm_writel(tdm, reg_int_status, int_status_mask); - zx_tdm_writel(tdm, reg_rx_fifo_ctrl, fifoctrl_rx_fifo_rst); - zx_tdm_writel(tdm, reg_tx_fifo_ctrl, fifoctrl_tx_fifo_rst); - - val = zx_tdm_readl(tdm, reg_rx_fifo_ctrl); - val &= ~(rxth_mask | rx_fifo_rst_mask); - val |= fifoctrl_threshold(8); - zx_tdm_writel(tdm, reg_rx_fifo_ctrl, val); - - val = zx_tdm_readl(tdm, reg_tx_fifo_ctrl); - val &= ~(txth_mask | tx_fifo_rst_mask); - val |= fifoctrl_threshold(8); - zx_tdm_writel(tdm, reg_tx_fifo_ctrl, val); -} - -static struct snd_soc_dai_driver zx_tdm_dai = { - .name = "zx-tdm-dai", - .id = 0, - .probe = zx_tdm_dai_probe, - .playback = { - .channels_min = 1, - .channels_max = 4, - .rates = zx_tdm_rates, - .formats = zx_tdm_fmtbit, - }, - .capture = { - .channels_min = 1, - .channels_max = 4, - .rates = zx_tdm_rates, - .formats = zx_tdm_fmtbit, - }, - .ops = &zx_tdm_dai_ops, -}; - -static int zx_tdm_probe(struct platform_device *pdev) -{ - struct of_phandle_args out_args; - unsigned int dma_reg_offset; - struct zx_tdm_info *zx_tdm; - unsigned int dma_mask; - struct resource *res; - struct regmap *regmap_sysctrl; - int ret; - - zx_tdm = devm_kzalloc(&pdev->dev, sizeof(*zx_tdm), gfp_kernel); - if (!zx_tdm) - return -enomem; - - zx_tdm->dev = &pdev->dev; - - zx_tdm->dai_wclk = devm_clk_get(&pdev->dev, "wclk"); - if (is_err(zx_tdm->dai_wclk)) { - dev_err(&pdev->dev, "fail to get wclk "); - return ptr_err(zx_tdm->dai_wclk); - } - - zx_tdm->dai_pclk = devm_clk_get(&pdev->dev, "pclk"); - if (is_err(zx_tdm->dai_pclk)) { - dev_err(&pdev->dev, "fail to get pclk "); - return ptr_err(zx_tdm->dai_pclk); - } - - res = platform_get_resource(pdev, ioresource_mem, 0); - zx_tdm->phy_addr = res->start; - zx_tdm->regbase = devm_ioremap_resource(&pdev->dev, res); - if (is_err(zx_tdm->regbase)) - return ptr_err(zx_tdm->regbase); - - ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node, - "zte,tdm-dma-sysctrl", 2, 0, &out_args); - if (ret) { - dev_err(&pdev->dev, "fail to get zte,tdm-dma-sysctrl "); - return ret; - } - - dma_reg_offset = out_args.args[0]; - dma_mask = out_args.args[1]; - regmap_sysctrl = syscon_node_to_regmap(out_args.np); - if (is_err(regmap_sysctrl)) { - of_node_put(out_args.np); - return ptr_err(regmap_sysctrl); - } - - regmap_update_bits(regmap_sysctrl, dma_reg_offset, dma_mask, dma_mask); - of_node_put(out_args.np); - - zx_tdm_init_state(zx_tdm); - platform_set_drvdata(pdev, zx_tdm); - - ret = devm_snd_soc_register_component(&pdev->dev, &zx_tdm_component, - &zx_tdm_dai, 1); - if (ret) { - dev_err(&pdev->dev, "register dai failed: %d ", ret); - return ret; - } - - ret = devm_snd_dmaengine_pcm_register(&pdev->dev, null, 0); - if (ret) - dev_err(&pdev->dev, "register platform pcm failed: %d ", ret); - - return ret; -} - -static const struct of_device_id zx_tdm_dt_ids[] = { - { .compatible = "zte,zx296718-tdm", }, - {} -}; -module_device_table(of, zx_tdm_dt_ids); - -static struct platform_driver tdm_driver = { - .probe = zx_tdm_probe, - .driver = { - .name = "zx-tdm", - .of_match_table = zx_tdm_dt_ids, - }, -}; -module_platform_driver(tdm_driver); - -module_author("baoyou xie <baoyou.xie@linaro.org>"); -module_description("zte tdm dai driver"); -module_license("gpl v2");
Audio
dc98f1d655ca4411b574b1bd2629e7132e502c1c
arnd bergmann
sound
soc
bindings, codecs, sound, zte
input: add n64 controller driver
this adds support for the four built-in controller ports on the nintendo 64 console. the n64 controller includes an analog stick, a d-pad, and several buttons.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add n64 controller driver
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['kconfig', 'c', 'makefile']
3
353
1
--- diff --git a/drivers/input/joystick/kconfig b/drivers/input/joystick/kconfig --- a/drivers/input/joystick/kconfig +++ b/drivers/input/joystick/kconfig +config joystick_n64 + bool "n64 controller" + depends on mach_nintendo64 + help + say y here if you want enable support for the four + built-in controller ports on the nintendo 64 console. + diff --git a/drivers/input/joystick/makefile b/drivers/input/joystick/makefile --- a/drivers/input/joystick/makefile +++ b/drivers/input/joystick/makefile +obj-$(config_joystick_n64) += n64joy.o - diff --git a/drivers/input/joystick/n64joy.c b/drivers/input/joystick/n64joy.c --- /dev/null +++ b/drivers/input/joystick/n64joy.c +// spdx-license-identifier: gpl-2.0 +/* + * support for the four n64 controllers. + * + * copyright (c) 2021 lauri kasanen + */ + +#define pr_fmt(fmt) kbuild_modname ": " fmt + +#include <linux/errno.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/limits.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/timer.h> + +module_author("lauri kasanen <cand@gmx.com>"); +module_description("driver for n64 controllers"); +module_license("gpl"); + +#define pif_ram 0x1fc007c0 + +#define si_dram_reg 0 +#define si_read_reg 1 +#define si_write_reg 4 +#define si_status_reg 6 + +#define si_status_dma_busy bit(0) +#define si_status_io_busy bit(1) + +#define n64_controller_id 0x0500 + +#define max_controllers 4 + +static const char *n64joy_phys[max_controllers] = { + "n64joy/port0", + "n64joy/port1", + "n64joy/port2", + "n64joy/port3", +}; + +struct n64joy_priv { + u64 si_buf[8] ____cacheline_aligned; + struct timer_list timer; + struct mutex n64joy_mutex; + struct input_dev *n64joy_dev[max_controllers]; + u32 __iomem *reg_base; + u8 n64joy_opened; +}; + +struct joydata { + unsigned int: 16; /* unused */ + unsigned int err: 2; + unsigned int: 14; /* unused */ + + union { + u32 data; + + struct { + unsigned int a: 1; + unsigned int b: 1; + unsigned int z: 1; + unsigned int start: 1; + unsigned int up: 1; + unsigned int down: 1; + unsigned int left: 1; + unsigned int right: 1; + unsigned int: 2; /* unused */ + unsigned int l: 1; + unsigned int r: 1; + unsigned int c_up: 1; + unsigned int c_down: 1; + unsigned int c_left: 1; + unsigned int c_right: 1; + signed int x: 8; + signed int y: 8; + }; + }; +}; + +static void n64joy_write_reg(u32 __iomem *reg_base, const u8 reg, const u32 value) +{ + writel(value, reg_base + reg); +} + +static u32 n64joy_read_reg(u32 __iomem *reg_base, const u8 reg) +{ + return readl(reg_base + reg); +} + +static void n64joy_wait_si_dma(u32 __iomem *reg_base) +{ + while (n64joy_read_reg(reg_base, si_status_reg) & + (si_status_dma_busy | si_status_io_busy)) + cpu_relax(); +} + +static void n64joy_exec_pif(struct n64joy_priv *priv, const u64 in[8]) +{ + unsigned long flags; + + dma_cache_wback_inv((unsigned long) in, 8 * 8); + dma_cache_inv((unsigned long) priv->si_buf, 8 * 8); + + local_irq_save(flags); + + n64joy_wait_si_dma(priv->reg_base); + + barrier(); + n64joy_write_reg(priv->reg_base, si_dram_reg, virt_to_phys(in)); + barrier(); + n64joy_write_reg(priv->reg_base, si_write_reg, pif_ram); + barrier(); + + n64joy_wait_si_dma(priv->reg_base); + + barrier(); + n64joy_write_reg(priv->reg_base, si_dram_reg, virt_to_phys(priv->si_buf)); + barrier(); + n64joy_write_reg(priv->reg_base, si_read_reg, pif_ram); + barrier(); + + n64joy_wait_si_dma(priv->reg_base); + + local_irq_restore(flags); +} + +static const u64 polldata[] ____cacheline_aligned = { + 0xff010401ffffffff, + 0xff010401ffffffff, + 0xff010401ffffffff, + 0xff010401ffffffff, + 0xfe00000000000000, + 0, + 0, + 1 +}; + +static void n64joy_poll(struct timer_list *t) +{ + const struct joydata *data; + struct n64joy_priv *priv = container_of(t, struct n64joy_priv, timer); + struct input_dev *dev; + u32 i; + + n64joy_exec_pif(priv, polldata); + + data = (struct joydata *) priv->si_buf; + + for (i = 0; i < max_controllers; i++) { + if (!priv->n64joy_dev[i]) + continue; + + dev = priv->n64joy_dev[i]; + + /* d-pad */ + input_report_key(dev, btn_dpad_up, data[i].up); + input_report_key(dev, btn_dpad_down, data[i].down); + input_report_key(dev, btn_dpad_left, data[i].left); + input_report_key(dev, btn_dpad_right, data[i].right); + + /* c buttons */ + input_report_key(dev, btn_forward, data[i].c_up); + input_report_key(dev, btn_back, data[i].c_down); + input_report_key(dev, btn_left, data[i].c_left); + input_report_key(dev, btn_right, data[i].c_right); + + /* matching buttons */ + input_report_key(dev, btn_start, data[i].start); + input_report_key(dev, btn_z, data[i].z); + + /* remaining ones: a, b, l, r */ + input_report_key(dev, btn_0, data[i].a); + input_report_key(dev, btn_1, data[i].b); + input_report_key(dev, btn_2, data[i].l); + input_report_key(dev, btn_3, data[i].r); + + input_report_abs(dev, abs_x, data[i].x); + input_report_abs(dev, abs_y, data[i].y); + + input_sync(dev); + } + + mod_timer(&priv->timer, jiffies + msecs_to_jiffies(16)); +} + +static int n64joy_open(struct input_dev *dev) +{ + struct n64joy_priv *priv = input_get_drvdata(dev); + int err; + + err = mutex_lock_interruptible(&priv->n64joy_mutex); + if (err) + return err; + + if (!priv->n64joy_opened) { + /* + * we could use the vblank irq, but it's not important if + * the poll point slightly changes. + */ + timer_setup(&priv->timer, n64joy_poll, 0); + mod_timer(&priv->timer, jiffies + msecs_to_jiffies(16)); + } + + priv->n64joy_opened++; + + mutex_unlock(&priv->n64joy_mutex); + return err; +} + +static void n64joy_close(struct input_dev *dev) +{ + struct n64joy_priv *priv = input_get_drvdata(dev); + + mutex_lock(&priv->n64joy_mutex); + if (!--priv->n64joy_opened) + del_timer_sync(&priv->timer); + mutex_unlock(&priv->n64joy_mutex); +} + +static const u64 __initconst scandata[] ____cacheline_aligned = { + 0xff010300ffffffff, + 0xff010300ffffffff, + 0xff010300ffffffff, + 0xff010300ffffffff, + 0xfe00000000000000, + 0, + 0, + 1 +}; + +/* + * the target device is embedded and ram-constrained. we save ram + * by initializing in __init code that gets dropped late in boot. + * for the same reason there is no module or unloading support. + */ +static int __init n64joy_probe(struct platform_device *pdev) +{ + const struct joydata *data; + struct n64joy_priv *priv; + struct input_dev *dev; + int err = 0; + u32 i, j, found = 0; + + priv = kzalloc(sizeof(struct n64joy_priv), gfp_kernel); + if (!priv) + return -enomem; + mutex_init(&priv->n64joy_mutex); + + priv->reg_base = devm_platform_ioremap_resource(pdev, 0); + if (!priv->reg_base) { + err = -einval; + goto fail; + } + + /* the controllers are not hotpluggable, so we can scan in init */ + n64joy_exec_pif(priv, scandata); + + data = (struct joydata *) priv->si_buf; + + for (i = 0; i < max_controllers; i++) { + if (!data[i].err && data[i].data >> 16 == n64_controller_id) { + found++; + + dev = priv->n64joy_dev[i] = input_allocate_device(); + if (!priv->n64joy_dev[i]) { + err = -enomem; + goto fail; + } + + input_set_drvdata(dev, priv); + + dev->name = "n64 controller"; + dev->phys = n64joy_phys[i]; + dev->id.bustype = bus_host; + dev->id.vendor = 0; + dev->id.product = data[i].data >> 16; + dev->id.version = 0; + dev->dev.parent = &pdev->dev; + + dev->open = n64joy_open; + dev->close = n64joy_close; + + /* d-pad */ + input_set_capability(dev, ev_key, btn_dpad_up); + input_set_capability(dev, ev_key, btn_dpad_down); + input_set_capability(dev, ev_key, btn_dpad_left); + input_set_capability(dev, ev_key, btn_dpad_right); + /* c buttons */ + input_set_capability(dev, ev_key, btn_left); + input_set_capability(dev, ev_key, btn_right); + input_set_capability(dev, ev_key, btn_forward); + input_set_capability(dev, ev_key, btn_back); + /* matching buttons */ + input_set_capability(dev, ev_key, btn_start); + input_set_capability(dev, ev_key, btn_z); + /* remaining ones: a, b, l, r */ + input_set_capability(dev, ev_key, btn_0); + input_set_capability(dev, ev_key, btn_1); + input_set_capability(dev, ev_key, btn_2); + input_set_capability(dev, ev_key, btn_3); + + for (j = 0; j < 2; j++) + input_set_abs_params(dev, abs_x + j, + s8_min, s8_max, 0, 0); + + err = input_register_device(dev); + if (err) { + input_free_device(dev); + goto fail; + } + } + } + + pr_info("%u controller(s) connected ", found); + + if (!found) + return -enodev; + + return 0; +fail: + for (i = 0; i < max_controllers; i++) { + if (!priv->n64joy_dev[i]) + continue; + input_unregister_device(priv->n64joy_dev[i]); + } + return err; +} + +static struct platform_driver n64joy_driver = { + .driver = { + .name = "n64joy", + }, +}; + +static int __init n64joy_init(void) +{ + return platform_driver_probe(&n64joy_driver, n64joy_probe); +} + +module_init(n64joy_init);
Tablets, touch screens, keyboards, mouses
3bdffa8ffb45c4f217d31a9250e90432ac31b35e
lauri kasanen
drivers
input
joystick
input: elants_i2c - add support for ektf3624
add elan ktf3624 touchscreen support to the elants_i2c driver. the ektf3624 ts is found on a series of asus transformer tablet devices, nexus 7 tablet and etc. the firmware interface of ektf3624 is nearly identical to ekth3500, which is already supported by the driver. the minor differences of the firmware interface are now handled by the driver. the ektf3624 support was tested on asus transformer tf700t, tf300t and nexus 7 tablets.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add support for ektf3624
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['elants_i2c']
['c']
1
135
17
--- diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c +#define queue_header_normal2 0x66 +#define packet_size_old 40 +#define e_elan_info_x_res 0x60 +#define e_elan_info_y_res 0x63 +enum elants_chip_id { + ekth3500, + ektf3624, +}; + + unsigned int phy_x; + unsigned int phy_y; + enum elants_chip_id chip_id; -static int elants_i2c_query_ts_info(struct elants_data *ts) +static int elants_i2c_query_ts_info_ektf(struct elants_data *ts) +{ + struct i2c_client *client = ts->client; + int error; + u8 resp[4]; + u16 phy_x, phy_y; + const u8 get_xres_cmd[] = { + cmd_header_read, e_elan_info_x_res, 0x00, 0x00 + }; + const u8 get_yres_cmd[] = { + cmd_header_read, e_elan_info_y_res, 0x00, 0x00 + }; + + /* get x/y size in mm */ + error = elants_i2c_execute_command(client, get_xres_cmd, + sizeof(get_xres_cmd), + resp, sizeof(resp), 1, + "get x size"); + if (error) + return error; + + phy_x = resp[2] | ((resp[3] & 0xf0) << 4); + + error = elants_i2c_execute_command(client, get_yres_cmd, + sizeof(get_yres_cmd), + resp, sizeof(resp), 1, + "get y size"); + if (error) + return error; + + phy_y = resp[2] | ((resp[3] & 0xf0) << 4); + + dev_dbg(&client->dev, "phy_x=%d, phy_y=%d ", phy_x, phy_y); + + ts->phy_x = phy_x; + ts->phy_y = phy_y; + + /* ektf doesn't report max size, set it to default values */ + ts->x_max = 2240 - 1; + ts->y_max = 1408 - 1; + + return 0; +} + +static int elants_i2c_query_ts_info_ekth(struct elants_data *ts) + ts->phy_x = phy_x; + ts->phy_y = phy_y; - if (!error) - error = elants_i2c_query_ts_info(ts); + + switch (ts->chip_id) { + case ekth3500: + if (!error) + error = elants_i2c_query_ts_info_ekth(ts); + break; + case ektf3624: + if (!error) + error = elants_i2c_query_ts_info_ektf(ts); + break; + default: + unreachable(); + break; + } -static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) +static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf, + size_t packet_size) - p = buf[fw_pos_pressure + i]; - w = buf[fw_pos_width + i]; + + /* + * ektf3624 may have use "old" touch-report format, + * depending on a device and ts firmware version. + * for example, asus transformer devices use the "old" + * format, while asus nexus 7 uses the "new" formant. + */ + if (packet_size == packet_size_old && + ts->chip_id == ektf3624) { + w = buf[fw_pos_width + i / 2]; + w >>= 4 * (~i & 1); + w |= w << 4; + w |= !w; + p = w; + } else { + p = buf[fw_pos_pressure + i]; + w = buf[fw_pos_width + i]; + } -static void elants_i2c_event(struct elants_data *ts, u8 *buf) +static void elants_i2c_event(struct elants_data *ts, u8 *buf, + size_t packet_size) - elants_i2c_mt_event(ts, buf); + elants_i2c_mt_event(ts, buf, packet_size); - case cmd_header_rek: - elants_i2c_event(ts, &ts->buf[header_size]); + elants_i2c_event(ts, &ts->buf[header_size], + ts->buf[fw_hdr_length]); + case queue_header_normal2: /* cmd_header_rek */ + /* + * depending on firmware version, ektf3624 touchscreens + * may utilize one of these opcodes for the touch events: + * 0x63 (normal) and 0x66 (normal2). the 0x63 is used by + * older firmware version and differs from 0x66 such that + * touch pressure value needs to be adjusted. the 0x66 + * opcode of newer firmware is equal to 0x63 of ekth3500. + */ + if (ts->chip_id != ektf3624) + break; + + fallthrough; + - if (report_len != packet_size) { + + if (report_len == packet_size_old && + ts->chip_id == ektf3624) { + dev_dbg_once(&client->dev, + "using old report format "); + } else if (report_len != packet_size) { - i * packet_size; - elants_i2c_event(ts, buf); + i * report_len; + elants_i2c_event(ts, buf, report_len); + ts->chip_id = (enum elants_chip_id)id->driver_data; + + touchscreen_parse_properties(ts->input, true, &ts->prop); + + if (ts->chip_id == ektf3624) { + /* calculate resolution from size */ + ts->x_res = div_round_closest(ts->prop.max_x, ts->phy_x); + ts->y_res = div_round_closest(ts->prop.max_y, ts->phy_y); + } + - touchscreen_parse_properties(ts->input, true, &ts->prop); - - { device_name, 0 }, + { device_name, ekth3500 }, + { "ekth3500", ekth3500 }, + { "ektf3624", ektf3624 }, - { "elan0001", 0 }, + { "elan0001", ekth3500 }, + { .compatible = "elan,ektf3624" },
Tablets, touch screens, keyboards, mouses
9517b95bdc4699d94c2ffc6a520bb0ccec396f5b
micha miros aw
drivers
input
touchscreen
input: xpad - add support for powera enhanced wired controller for xbox series x|s
signed-off-by: olivier crete <olivier.crete@ocrete.ca> link: https://lore.kernel.org/r/20210204005318.615647-1-olivier.crete@collabora.com cc: stable@vger.kernel.org signed-off-by: dmitry torokhov <dmitry.torokhov@gmail.com>
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add support for powera enhanced wired controller for xbox series x|s
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['xpad']
['c']
1
1
0
--- diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c + { 0x20d6, 0x2009, "powera enhanced wired controller for xbox series x|s", 0, xtype_xboxone },
Tablets, touch screens, keyboards, mouses
42ffcd1dba1796bcda386eb6f260df9fc23c90af
olivier cr te
drivers
input
joystick
input: cros-ec-keyb - expose function row physical map to userspace
the top-row keys in a keyboard usually have dual functionalities. e.g. a function key "f1" is also an action key "browser back".
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
expose function row physical map to userspace
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['cros-ec-keyb']
['c', 'sysfs-driver-input-cros-ec-keyb']
2
85
0
--- diff --git a/documentation/abi/testing/sysfs-driver-input-cros-ec-keyb b/documentation/abi/testing/sysfs-driver-input-cros-ec-keyb --- /dev/null +++ b/documentation/abi/testing/sysfs-driver-input-cros-ec-keyb +what: /sys/class/input/input(x)/device/function_row_physmap +date: january 2021 +contact: philip chen <philipchen@chromium.org> +description: a space separated list of scancodes for the top row keys, + ordered by the physical positions of the keys, from left + to right. diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c +#define max_num_top_row_keys 15 + + * @function_row_physmap: an array of the encoded rows/columns for the top + * row function keys, in an order from left to right + * @num_function_row_keys: the number of top row keys in a custom keyboard + + u16 function_row_physmap[max_num_top_row_keys]; + size_t num_function_row_keys; + struct property *prop; + const __be32 *p; + u16 *physmap; + u32 key_pos; + int row, col; + physmap = ckdev->function_row_physmap; + of_property_for_each_u32(dev->of_node, "function-row-physmap", + prop, p, key_pos) { + if (ckdev->num_function_row_keys == max_num_top_row_keys) { + dev_warn(dev, "only support up to %d top row keys ", + max_num_top_row_keys); + break; + } + row = key_row(key_pos); + col = key_col(key_pos); + *physmap = matrix_scan_code(row, col, ckdev->row_shift); + physmap++; + ckdev->num_function_row_keys++; + } + +static ssize_t function_row_physmap_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t size = 0; + int i; + struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); + u16 *physmap = ckdev->function_row_physmap; + + for (i = 0; i < ckdev->num_function_row_keys; i++) + size += scnprintf(buf + size, page_size - size, + "%s%02x", size ? " " : "", physmap[i]); + if (size) + size += scnprintf(buf + size, page_size - size, " "); + + return size; +} + +static device_attr_ro(function_row_physmap); + +static struct attribute *cros_ec_keyb_attrs[] = { + &dev_attr_function_row_physmap.attr, + null, +}; + +static umode_t cros_ec_keyb_attr_is_visible(struct kobject *kobj, + struct attribute *attr, + int n) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); + + if (attr == &dev_attr_function_row_physmap.attr && + !ckdev->num_function_row_keys) + return 0; + + return attr->mode; +} + +static const struct attribute_group cros_ec_keyb_attr_group = { + .is_visible = cros_ec_keyb_attr_is_visible, + .attrs = cros_ec_keyb_attrs, +}; + + + err = devm_device_add_group(dev, &cros_ec_keyb_attr_group); + if (err) { + dev_err(dev, "failed to create attributes. err=%d ", err); + return err; + } +
Tablets, touch screens, keyboards, mouses
820c8727956da82b7a841c299fabb2fdca9a37d4
philip chen
drivers
input
keyboard, testing
hid: chicony: add wireless radio control feature for chicony devices
some chicony's keyboards support airplane mode hotkey (fn+f2) with "wireless radio control" feature. for example, the wireless keyboard [04f2:1236] shipped with asus all-in-one desktop.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add wireless radio control feature for chicony devices
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'chicony']
['h', 'c']
2
56
0
--- diff --git a/drivers/hid/hid-chicony.c b/drivers/hid/hid-chicony.c --- a/drivers/hid/hid-chicony.c +++ b/drivers/hid/hid-chicony.c +#define ch_wireless_ctl_report_id 0x11 + +static int ch_report_wireless(struct hid_report *report, u8 *data, int size) +{ + struct hid_device *hdev = report->device; + struct input_dev *input; + + if (report->id != ch_wireless_ctl_report_id || report->maxfield != 1) + return 0; + + input = report->field[0]->hidinput->input; + if (!input) { + hid_warn(hdev, "can't find wireless radio control's input"); + return 0; + } + + input_report_key(input, key_rfkill, 1); + input_sync(input); + input_report_key(input, key_rfkill, 0); + input_sync(input); + + return 1; +} + +static int ch_raw_event(struct hid_device *hdev, + struct hid_report *report, u8 *data, int size) +{ + if (report->application == hid_gd_wireless_radio_ctls) + return ch_report_wireless(report, data, size); + + return 0; +} + +static int ch_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + int ret; + + hdev->quirks |= hid_quirk_input_per_app; + ret = hid_parse(hdev); + if (ret) { + hid_err(hdev, "chicony hid parse failed: %d ", ret); + return ret; + } + + ret = hid_hw_start(hdev, hid_connect_default); + if (ret) { + hid_err(hdev, "chicony hw start failed: %d ", ret); + return ret; + } + + return 0; +} + { hid_usb_device(usb_vendor_id_chicony, usb_device_id_chicony_wireless3) }, + .probe = ch_probe, + .raw_event = ch_raw_event, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h +#define usb_device_id_chicony_wireless3 0x1236
Tablets, touch screens, keyboards, mouses
859b510bb7fa5797cfaf7bf5729336bf0e94dd2e
jian hong pan
drivers
hid
hid: hid-sensor-custom: add custom sensor iio support
currently custom sensors properties are not decoded and it is up to user space to interpret.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add custom sensor iio support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'hid-sensor-custom']
['h', 'c']
2
157
0
--- diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c --- a/drivers/hid/hid-sensor-custom.c +++ b/drivers/hid/hid-sensor-custom.c +#include <linux/ctype.h> +#define hid_sensor_usage_length (4 + 1) + struct platform_device *custom_pdev; +/* luid defined in fw (e.g. ish). maybe used to identify sensor. */ +static const char *const known_sensor_luid[] = { "020b000000000000" }; + +static int get_luid_table_index(unsigned char *usage_str) +{ + int i; + + for (i = 0; i < array_size(known_sensor_luid); i++) { + if (!strncmp(usage_str, known_sensor_luid[i], + strlen(known_sensor_luid[i]))) + return i; + } + + return -enodev; +} + +static int get_known_custom_sensor_index(struct hid_sensor_hub_device *hsdev) +{ + struct hid_sensor_hub_attribute_info sensor_manufacturer = { 0 }; + struct hid_sensor_hub_attribute_info sensor_luid_info = { 0 }; + int report_size; + int ret; + static u16 w_buf[hid_custom_max_feature_bytes]; + static char buf[hid_custom_max_feature_bytes]; + int i; + + memset(w_buf, 0, sizeof(w_buf)); + memset(buf, 0, sizeof(buf)); + + /* get manufacturer info */ + ret = sensor_hub_input_get_attribute_info(hsdev, + hid_feature_report, hsdev->usage, + hid_usage_sensor_prop_manufacturer, &sensor_manufacturer); + if (ret < 0) + return ret; + + report_size = + sensor_hub_get_feature(hsdev, sensor_manufacturer.report_id, + sensor_manufacturer.index, sizeof(w_buf), + w_buf); + if (report_size <= 0) { + hid_err(hsdev->hdev, + "failed to get sensor manufacturer info %d ", + report_size); + return -enodev; + } + + /* convert from wide char to char */ + for (i = 0; i < array_size(buf) - 1 && w_buf[i]; i++) + buf[i] = (char)w_buf[i]; + + /* ensure it's ish sensor */ + if (strncmp(buf, "intel", strlen("intel"))) + return -enodev; + + memset(w_buf, 0, sizeof(w_buf)); + memset(buf, 0, sizeof(buf)); + + /* get real usage id */ + ret = sensor_hub_input_get_attribute_info(hsdev, + hid_feature_report, hsdev->usage, + hid_usage_sensor_prop_serial_num, &sensor_luid_info); + if (ret < 0) + return ret; + + report_size = sensor_hub_get_feature(hsdev, sensor_luid_info.report_id, + sensor_luid_info.index, sizeof(w_buf), + w_buf); + if (report_size <= 0) { + hid_err(hsdev->hdev, "failed to get real usage info %d ", + report_size); + return -enodev; + } + + /* convert from wide char to char */ + for (i = 0; i < array_size(buf) - 1 && w_buf[i]; i++) + buf[i] = (char)w_buf[i]; + + if (strlen(buf) != strlen(known_sensor_luid[0]) + 5) { + hid_err(hsdev->hdev, + "%s luid length not match %zu != (%zu + 5) ", __func__, + strlen(buf), strlen(known_sensor_luid[0])); + return -enodev; + } + + /* get table index with luid (not matching 'luid: ' in luid) */ + return get_luid_table_index(&buf[5]); +} + +static struct platform_device * +hid_sensor_register_platform_device(struct platform_device *pdev, + struct hid_sensor_hub_device *hsdev, + int index) +{ + char real_usage[hid_sensor_usage_length] = { 0 }; + struct platform_device *custom_pdev; + const char *dev_name; + char *c; + + /* copy real usage id */ + memcpy(real_usage, known_sensor_luid[index], 4); + + /* usage id are all lowcase */ + for (c = real_usage; *c != ''; c++) + *c = tolower(*c); + + /* hid-sensor-int-real_usage_id */ + dev_name = kasprintf(gfp_kernel, "hid-sensor-int-%s", real_usage); + if (!dev_name) + return err_ptr(-enomem); + + custom_pdev = platform_device_register_data(pdev->dev.parent, dev_name, + platform_devid_none, hsdev, + sizeof(*hsdev)); + kfree(dev_name); + return custom_pdev; +} + + int index; + + index = get_known_custom_sensor_index(hsdev); + if (index >= 0 && index < array_size(known_sensor_luid)) { + sensor_inst->custom_pdev = + hid_sensor_register_platform_device(pdev, hsdev, index); + + ret = ptr_err_or_zero(sensor_inst->custom_pdev); + if (ret) { + dev_err(&pdev->dev, + "register_platform_device failed "); + return ret; + } + + return 0; + } + + if (sensor_inst->custom_pdev) { + platform_device_unregister(sensor_inst->custom_pdev); + return 0; + } + diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h +#define hid_usage_sensor_prop_desc 0x200300 +#define hid_usage_sensor_prop_friendly_name 0x200301 +#define hid_usage_sensor_prop_serial_num 0x200307 +#define hid_usage_sensor_prop_manufacturer 0x200305 +/* custom sensor (2000e1) */ +#define hid_usage_sensor_hinge 0x20020b +#define hid_usage_sensor_data_field_location 0x200400 +#define hid_usage_sensor_data_fiele_time_since_sys_boot 0x20052b +#define hid_usage_sensor_data_field_custom_usage 0x200541 +#define hid_usage_sensor_data_field_custom_value_base 0x200543 +/* custom sensor data 28=>x>=0 */ +#define hid_usage_sensor_data_field_custom_value(x) \ + (hid_usage_sensor_data_field_custom_value_base + (x)) +
Tablets, touch screens, keyboards, mouses
239319670e2a7c405eeb4b3e7721cf8bf8eef840
ye xiang
drivers
hid
hid: i2c-hid: add i2c_hid_quirk_no_irq_after_reset for ite8568 ec on voyo winpad a15
the ite8568 ec on the voyo winpad a15 presents itself as an i2c-hid attached keyboard and mouse (which seems to never send any events).
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add i2c_hid_quirk_no_irq_after_reset for ite8568 ec on voyo winpad a15
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'i2c-hid']
['h', 'c']
2
4
0
--- diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h +#define i2c_vendor_id_ite 0x103c +#define i2c_device_id_ite_voyo_winpad_a15 0x184f diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c + { i2c_vendor_id_ite, i2c_device_id_ite_voyo_winpad_a15, + i2c_hid_quirk_no_irq_after_reset },
Tablets, touch screens, keyboards, mouses
fc6a31b00739356809dd566e16f2c4325a63285d
hans de goede
drivers
hid
i2c-hid
hid: i2c-hid: introduce goodix-i2c-hid using i2c-hid core
goodix i2c-hid touchscreens are mostly i2c-hid compliant but have some special power sequencing requirements, including the need to drive a reset line during the sequencing.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
introduce goodix-i2c-hid using i2c-hid core
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'i2c-hid']
['kconfig', 'c', 'makefile']
3
134
2
--- diff --git a/drivers/hid/i2c-hid/kconfig b/drivers/hid/i2c-hid/kconfig --- a/drivers/hid/i2c-hid/kconfig +++ b/drivers/hid/i2c-hid/kconfig +config i2c_hid_of_goodix + tristate "driver for goodix hid-i2c based devices on of systems" + default n + depends on i2c && input && of + help + say y here if you want support for goodix i2c devices that use + the i2c-hid protocol on open firmware (device tree)-based + systems. + + if unsure, say n. + + this support is also available as a module. if so, the module + will be called i2c-hid-of-goodix. it will also build/depend on + the module i2c-hid. + - default y if i2c_hid_acpi=y || i2c_hid_of=y - default m if i2c_hid_acpi=m || i2c_hid_of=m + default y if i2c_hid_acpi=y || i2c_hid_of=y || i2c_hid_of_goodix=y + default m if i2c_hid_acpi=m || i2c_hid_of=m || i2c_hid_of_goodix=m diff --git a/drivers/hid/i2c-hid/makefile b/drivers/hid/i2c-hid/makefile --- a/drivers/hid/i2c-hid/makefile +++ b/drivers/hid/i2c-hid/makefile +obj-$(config_i2c_hid_of_goodix) += i2c-hid-of-goodix.o diff --git a/drivers/hid/i2c-hid/i2c-hid-of-goodix.c b/drivers/hid/i2c-hid/i2c-hid-of-goodix.c --- /dev/null +++ b/drivers/hid/i2c-hid/i2c-hid-of-goodix.c +// spdx-license-identifier: gpl-2.0 +/* + * driver for goodix touchscreens that use the i2c-hid protocol. + * + * copyright 2020 google llc + */ + +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/pm.h> +#include <linux/regulator/consumer.h> + +#include "i2c-hid.h" + +struct goodix_i2c_hid_timing_data { + unsigned int post_gpio_reset_delay_ms; + unsigned int post_power_delay_ms; +}; + +struct i2c_hid_of_goodix { + struct i2chid_ops ops; + + struct regulator *vdd; + struct gpio_desc *reset_gpio; + const struct goodix_i2c_hid_timing_data *timings; +}; + +static int goodix_i2c_hid_power_up(struct i2chid_ops *ops) +{ + struct i2c_hid_of_goodix *ihid_goodix = + container_of(ops, struct i2c_hid_of_goodix, ops); + int ret; + + ret = regulator_enable(ihid_goodix->vdd); + if (ret) + return ret; + + if (ihid_goodix->timings->post_power_delay_ms) + msleep(ihid_goodix->timings->post_power_delay_ms); + + gpiod_set_value_cansleep(ihid_goodix->reset_gpio, 0); + if (ihid_goodix->timings->post_gpio_reset_delay_ms) + msleep(ihid_goodix->timings->post_gpio_reset_delay_ms); + + return 0; +} + +static void goodix_i2c_hid_power_down(struct i2chid_ops *ops) +{ + struct i2c_hid_of_goodix *ihid_goodix = + container_of(ops, struct i2c_hid_of_goodix, ops); + + gpiod_set_value_cansleep(ihid_goodix->reset_gpio, 1); + regulator_disable(ihid_goodix->vdd); +} + +static int i2c_hid_of_goodix_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_hid_of_goodix *ihid_goodix; + + ihid_goodix = devm_kzalloc(&client->dev, sizeof(*ihid_goodix), + gfp_kernel); + if (!ihid_goodix) + return -enomem; + + ihid_goodix->ops.power_up = goodix_i2c_hid_power_up; + ihid_goodix->ops.power_down = goodix_i2c_hid_power_down; + + /* start out with reset asserted */ + ihid_goodix->reset_gpio = + devm_gpiod_get_optional(&client->dev, "reset", gpiod_out_high); + if (is_err(ihid_goodix->reset_gpio)) + return ptr_err(ihid_goodix->reset_gpio); + + ihid_goodix->vdd = devm_regulator_get(&client->dev, "vdd"); + if (is_err(ihid_goodix->vdd)) + return ptr_err(ihid_goodix->vdd); + + ihid_goodix->timings = device_get_match_data(&client->dev); + + return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001); +} + +static const struct goodix_i2c_hid_timing_data goodix_gt7375p_timing_data = { + .post_power_delay_ms = 10, + .post_gpio_reset_delay_ms = 180, +}; + +static const struct of_device_id goodix_i2c_hid_of_match[] = { + { .compatible = "goodix,gt7375p", .data = &goodix_gt7375p_timing_data }, + { } +}; +module_device_table(of, goodix_i2c_hid_of_match); + +static struct i2c_driver goodix_i2c_hid_ts_driver = { + .driver = { + .name = "i2c_hid_of_goodix", + .pm = &i2c_hid_core_pm, + .probe_type = probe_prefer_asynchronous, + .of_match_table = of_match_ptr(goodix_i2c_hid_of_match), + }, + .probe = i2c_hid_of_goodix_probe, + .remove = i2c_hid_core_remove, + .shutdown = i2c_hid_core_shutdown, +}; +module_i2c_driver(goodix_i2c_hid_ts_driver); + +module_author("douglas anderson <dianders@chromium.org>"); +module_description("goodix i2c-hid touchscreen driver"); +module_license("gpl v2");
Tablets, touch screens, keyboards, mouses
c1ed18c11bdb80eced208a61d40b1988f36a014f
douglas anderson
drivers
hid
i2c-hid
hid: intel-ish-hid: ipc: add tiger lake h pci device id
added tiger lake h pci device id to the supported device list.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add tiger lake h pci device id
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'intel-ish-hid', 'ipc']
['h', 'c']
2
2
0
--- diff --git a/drivers/hid/intel-ish-hid/ipc/hw-ish.h b/drivers/hid/intel-ish-hid/ipc/hw-ish.h --- a/drivers/hid/intel-ish-hid/ipc/hw-ish.h +++ b/drivers/hid/intel-ish-hid/ipc/hw-ish.h +#define tgl_h_device_id 0x43fc diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c --- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c +++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c + {pci_device(pci_vendor_id_intel, tgl_h_device_id)},
Tablets, touch screens, keyboards, mouses
2aefba190f17a3f409292ee9fc8f00c20fed411e
you sheng yang srinivas pandruvada srinivas pandruvada linux intel com
drivers
hid
intel-ish-hid, ipc
hid: logitech-dj: add support for keyboard events in equad step 4 gaming
in e400071a805d6229223a98899e9da8c6233704a1 i added support for the receiver that comes with the g602 device, but unfortunately i screwed up during testing and it seems the keyboard events were actually not being sent to userspace. this resulted in keyboard events being broken in userspace, please backport the fix.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add support for keyboard events in equad step 4 gaming
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'logitech-dj']
['c']
1
1
0
--- diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c + workitem.reports_supported |= std_keyboard;
Tablets, touch screens, keyboards, mouses
ef07c116d98772952807492bd32a61f5af172a94
filipe la ns
drivers
hid
hid: logitech-dj: add support for the new lightspeed connection iteration
this new connection type is the new iteration of the lightspeed connection and will probably be used in some of the newer gaming devices. it is currently use in the g pro x superlight.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add support for the new lightspeed connection iteration
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'logitech-dj']
['c']
1
6
1
--- diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c - device_type = "equad lightspeed 1_1"; + device_type = "equad lightspeed 1.1"; + logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); + workitem.reports_supported |= std_keyboard; + break; + case 0x0f: + device_type = "equad lightspeed 1.2";
Tablets, touch screens, keyboards, mouses
fab3a95654eea01d6b0204995be8b7492a00d001
filipe la ns
drivers
hid
hid: logitech-hidpp: add support for unified battery (1004) feature
this new feature present in new devices replaces the old battery level status (0x1000) feature. it keeps essentially the same information for levels (reporting critical, low, good and full) but makes these levels optional, the device exports a capability setting which describes which levels it supports. in addition to this, there is an optional state_of_charge paramenter that exports the battery percentage.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add support for unified battery (1004) feature
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'logitech-hidpp']
['c']
1
239
7
--- diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c +#define hidpp_capability_battery_percentage bit(5) +#define hidpp_capability_unified_battery bit(6) + u8 supported_levels_1004; -static int hidpp20_query_battery_info(struct hidpp_device *hidpp) +static int hidpp20_query_battery_info_1000(struct hidpp_device *hidpp) -static int hidpp20_battery_event(struct hidpp_device *hidpp, +static int hidpp20_battery_event_1000(struct hidpp_device *hidpp, +/* -------------------------------------------------------------------------- */ +/* 0x1004: unified battery */ +/* -------------------------------------------------------------------------- */ + +#define hidpp_page_unified_battery 0x1004 + +#define cmd_unified_battery_get_capabilities 0x00 +#define cmd_unified_battery_get_status 0x10 + +#define event_unified_battery_status_event 0x00 + +#define flag_unified_battery_level_critical bit(0) +#define flag_unified_battery_level_low bit(1) +#define flag_unified_battery_level_good bit(2) +#define flag_unified_battery_level_full bit(3) + +#define flag_unified_battery_flags_rechargeable bit(0) +#define flag_unified_battery_flags_state_of_charge bit(1) + +static int hidpp20_unifiedbattery_get_capabilities(struct hidpp_device *hidpp, + u8 feature_index) +{ + struct hidpp_report response; + int ret; + u8 *params = (u8 *)response.fap.params; + + if (hidpp->capabilities & hidpp_capability_battery_level_status || + hidpp->capabilities & hidpp_capability_battery_percentage) { + /* we have already set the device capabilities, so let's skip */ + return 0; + } + + ret = hidpp_send_fap_command_sync(hidpp, feature_index, + cmd_unified_battery_get_capabilities, + null, 0, &response); + /* ignore these intermittent errors */ + if (ret == hidpp_error_resource_error) + return -eio; + if (ret > 0) { + hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x ", + __func__, ret); + return -eproto; + } + if (ret) + return ret; + + /* + * if the device supports state of charge (battery percentage) we won't + * export the battery level information. there are 4 possible battery + * levels and they all are optional, this means that the device might + * not support any of them, we are just better off with the battery + * percentage. + */ + if (params[1] & flag_unified_battery_flags_state_of_charge) { + hidpp->capabilities |= hidpp_capability_battery_percentage; + hidpp->battery.supported_levels_1004 = 0; + } else { + hidpp->capabilities |= hidpp_capability_battery_level_status; + hidpp->battery.supported_levels_1004 = params[0]; + } + + return 0; +} + +static int hidpp20_unifiedbattery_map_status(struct hidpp_device *hidpp, + u8 charging_status, + u8 external_power_status) +{ + int status; + + switch (charging_status) { + case 0: /* discharging */ + status = power_supply_status_discharging; + break; + case 1: /* charging */ + case 2: /* charging slow */ + status = power_supply_status_charging; + break; + case 3: /* complete */ + status = power_supply_status_full; + break; + case 4: /* error */ + status = power_supply_status_not_charging; + hid_info(hidpp->hid_dev, "%s: charging error", + hidpp->name); + break; + default: + status = power_supply_status_not_charging; + break; + } + + return status; +} + +static int hidpp20_unifiedbattery_map_level(struct hidpp_device *hidpp, + u8 battery_level) +{ + /* cler unsupported level bits */ + battery_level &= hidpp->battery.supported_levels_1004; + + if (battery_level & flag_unified_battery_level_full) + return power_supply_capacity_level_full; + else if (battery_level & flag_unified_battery_level_good) + return power_supply_capacity_level_normal; + else if (battery_level & flag_unified_battery_level_low) + return power_supply_capacity_level_low; + else if (battery_level & flag_unified_battery_level_critical) + return power_supply_capacity_level_critical; + + return power_supply_capacity_level_unknown; +} + +static int hidpp20_unifiedbattery_get_status(struct hidpp_device *hidpp, + u8 feature_index, + u8 *state_of_charge, + int *status, + int *level) +{ + struct hidpp_report response; + int ret; + u8 *params = (u8 *)response.fap.params; + + ret = hidpp_send_fap_command_sync(hidpp, feature_index, + cmd_unified_battery_get_status, + null, 0, &response); + /* ignore these intermittent errors */ + if (ret == hidpp_error_resource_error) + return -eio; + if (ret > 0) { + hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x ", + __func__, ret); + return -eproto; + } + if (ret) + return ret; + + *state_of_charge = params[0]; + *status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); + *level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); + + return 0; +} + +static int hidpp20_query_battery_info_1004(struct hidpp_device *hidpp) +{ + u8 feature_type; + int ret; + u8 state_of_charge; + int status, level; + + if (hidpp->battery.feature_index == 0xff) { + ret = hidpp_root_get_feature(hidpp, + hidpp_page_unified_battery, + &hidpp->battery.feature_index, + &feature_type); + if (ret) + return ret; + } + + ret = hidpp20_unifiedbattery_get_capabilities(hidpp, + hidpp->battery.feature_index); + if (ret) + return ret; + + ret = hidpp20_unifiedbattery_get_status(hidpp, + hidpp->battery.feature_index, + &state_of_charge, + &status, + &level); + if (ret) + return ret; + + hidpp->capabilities |= hidpp_capability_unified_battery; + hidpp->battery.capacity = state_of_charge; + hidpp->battery.status = status; + hidpp->battery.level = level; + hidpp->battery.online = true; + + return 0; +} + +static int hidpp20_battery_event_1004(struct hidpp_device *hidpp, + u8 *data, int size) +{ + struct hidpp_report *report = (struct hidpp_report *)data; + u8 *params = (u8 *)report->fap.params; + int state_of_charge, status, level; + bool changed; + + if (report->fap.feature_index != hidpp->battery.feature_index || + report->fap.funcindex_clientid != event_unified_battery_status_event) + return 0; + + state_of_charge = params[0]; + status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); + level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); + + changed = status != hidpp->battery.status || + (state_of_charge != hidpp->battery.capacity && + hidpp->capabilities & hidpp_capability_battery_percentage) || + (level != hidpp->battery.level && + hidpp->capabilities & hidpp_capability_battery_level_status); + + if (changed) { + hidpp->battery.capacity = state_of_charge; + hidpp->battery.status = status; + hidpp->battery.level = level; + if (hidpp->battery.ps) + power_supply_changed(hidpp->battery.ps); + } + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* battery feature helpers */ +/* -------------------------------------------------------------------------- */ + - ret = hidpp20_battery_event(hidpp, data, size); + ret = hidpp20_battery_event_1000(hidpp, data, size); + if (ret != 0) + return ret; + ret = hidpp20_battery_event_1004(hidpp, data, size); - ret = hidpp20_query_battery_voltage_info(hidpp); + /* we only support one battery feature right now, so let's + first check the ones that support battery level first + and leave voltage for last */ + ret = hidpp20_query_battery_info_1000(hidpp); + if (ret) + ret = hidpp20_query_battery_info_1004(hidpp); - ret = hidpp20_query_battery_info(hidpp); + ret = hidpp20_query_battery_voltage_info(hidpp); - if (hidpp->capabilities & hidpp_capability_battery_mileage) + if (hidpp->capabilities & hidpp_capability_battery_mileage || + hidpp->capabilities & hidpp_capability_battery_percentage) + else if (hidpp->capabilities & hidpp_capability_unified_battery) + hidpp20_query_battery_info_1004(hidpp); - hidpp20_query_battery_info(hidpp); + hidpp20_query_battery_info_1000(hidpp);
Tablets, touch screens, keyboards, mouses
e037acf0b1aed31cb5f3b09ccb602b4768c133d5
filipe la ns
drivers
hid
hid: playstation: initial dualsense usb support.
implement support for playstation dualsense gamepad in usb mode. support features include buttons and sticks, which adhere to the linux gamepad spec.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['c', 'h', 'kconfig', 'maintainers', 'makefile']
5
344
0
--- diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers +hid playstation driver +m: roderick colenbrander <roderick.colenbrander@sony.com> +l: linux-input@vger.kernel.org +s: supported +f: drivers/hid/hid-playstation.c + diff --git a/drivers/hid/kconfig b/drivers/hid/kconfig --- a/drivers/hid/kconfig +++ b/drivers/hid/kconfig +config hid_playstation + tristate "playstation hid driver" + depends on hid + help + provides support for sony ps5 controllers including support for + its special functionalities e.g. touchpad, lights and motion + sensors. + diff --git a/drivers/hid/makefile b/drivers/hid/makefile --- a/drivers/hid/makefile +++ b/drivers/hid/makefile +obj-$(config_hid_playstation) += hid-playstation.o diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h +#define usb_device_id_sony_ps5_controller 0x0ce6 diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- /dev/null +++ b/drivers/hid/hid-playstation.c +// spdx-license-identifier: gpl-2.0-or-later +/* + * hid driver for sony dualsense(tm) controller. + * + * copyright (c) 2020 sony interactive entertainment + */ + +#include <linux/bits.h> +#include <linux/device.h> +#include <linux/hid.h> +#include <linux/input/mt.h> +#include <linux/module.h> + +#include <asm/unaligned.h> + +#include "hid-ids.h" + +#define hid_playstation_version_patch 0x8000 + +/* base class for playstation devices. */ +struct ps_device { + struct hid_device *hdev; + + int (*parse_report)(struct ps_device *dev, struct hid_report *report, u8 *data, int size); +}; + +#define ds_input_report_usb 0x01 +#define ds_input_report_usb_size 64 + +/* button masks for dualsense input report. */ +#define ds_buttons0_hat_switch genmask(3, 0) +#define ds_buttons0_square bit(4) +#define ds_buttons0_cross bit(5) +#define ds_buttons0_circle bit(6) +#define ds_buttons0_triangle bit(7) +#define ds_buttons1_l1 bit(0) +#define ds_buttons1_r1 bit(1) +#define ds_buttons1_l2 bit(2) +#define ds_buttons1_r2 bit(3) +#define ds_buttons1_create bit(4) +#define ds_buttons1_options bit(5) +#define ds_buttons1_l3 bit(6) +#define ds_buttons1_r3 bit(7) +#define ds_buttons2_ps_home bit(0) +#define ds_buttons2_touchpad bit(1) + +struct dualsense { + struct ps_device base; + struct input_dev *gamepad; +}; + +struct dualsense_touch_point { + uint8_t contact; + uint8_t x_lo; + uint8_t x_hi:4, y_lo:4; + uint8_t y_hi; +} __packed; +static_assert(sizeof(struct dualsense_touch_point) == 4); + +/* main dualsense input report excluding any bt/usb specific headers. */ +struct dualsense_input_report { + uint8_t x, y; + uint8_t rx, ry; + uint8_t z, rz; + uint8_t seq_number; + uint8_t buttons[4]; + uint8_t reserved[4]; + + /* motion sensors */ + __le16 gyro[3]; /* x, y, z */ + __le16 accel[3]; /* x, y, z */ + __le32 sensor_timestamp; + uint8_t reserved2; + + /* touchpad */ + struct dualsense_touch_point points[2]; + + uint8_t reserved3[12]; + uint8_t status; + uint8_t reserved4[10]; +} __packed; +/* common input report size shared equals the size of the usb report minus 1 byte for reportid. */ +static_assert(sizeof(struct dualsense_input_report) == ds_input_report_usb_size - 1); + +/* + * common gamepad buttons across dualshock 3 / 4 and dualsense. + * note: for device with a touchpad, touchpad button is not included + * as it will be part of the touchpad device. + */ +static const int ps_gamepad_buttons[] = { + btn_west, /* square */ + btn_north, /* triangle */ + btn_east, /* circle */ + btn_south, /* cross */ + btn_tl, /* l1 */ + btn_tr, /* r1 */ + btn_tl2, /* l2 */ + btn_tr2, /* r2 */ + btn_select, /* create (ps5) / share (ps4) */ + btn_start, /* option */ + btn_thumbl, /* l3 */ + btn_thumbr, /* r3 */ + btn_mode, /* ps home */ +}; + +static const struct {int x; int y; } ps_gamepad_hat_mapping[] = { + {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, + {0, 0}, +}; + +static struct input_dev *ps_allocate_input_dev(struct hid_device *hdev, const char *name_suffix) +{ + struct input_dev *input_dev; + + input_dev = devm_input_allocate_device(&hdev->dev); + if (!input_dev) + return err_ptr(-enomem); + + input_dev->id.bustype = hdev->bus; + input_dev->id.vendor = hdev->vendor; + input_dev->id.product = hdev->product; + input_dev->id.version = hdev->version; + input_dev->uniq = hdev->uniq; + + if (name_suffix) { + input_dev->name = devm_kasprintf(&hdev->dev, gfp_kernel, "%s %s", hdev->name, + name_suffix); + if (!input_dev->name) + return err_ptr(-enomem); + } else { + input_dev->name = hdev->name; + } + + input_set_drvdata(input_dev, hdev); + + return input_dev; +} + +static struct input_dev *ps_gamepad_create(struct hid_device *hdev) +{ + struct input_dev *gamepad; + unsigned int i; + int ret; + + gamepad = ps_allocate_input_dev(hdev, null); + if (is_err(gamepad)) + return err_cast(gamepad); + + input_set_abs_params(gamepad, abs_x, 0, 255, 0, 0); + input_set_abs_params(gamepad, abs_y, 0, 255, 0, 0); + input_set_abs_params(gamepad, abs_z, 0, 255, 0, 0); + input_set_abs_params(gamepad, abs_rx, 0, 255, 0, 0); + input_set_abs_params(gamepad, abs_ry, 0, 255, 0, 0); + input_set_abs_params(gamepad, abs_rz, 0, 255, 0, 0); + + input_set_abs_params(gamepad, abs_hat0x, -1, 1, 0, 0); + input_set_abs_params(gamepad, abs_hat0y, -1, 1, 0, 0); + + for (i = 0; i < array_size(ps_gamepad_buttons); i++) + input_set_capability(gamepad, ev_key, ps_gamepad_buttons[i]); + + ret = input_register_device(gamepad); + if (ret) + return err_ptr(ret); + + return gamepad; +} + +static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *report, + u8 *data, int size) +{ + struct hid_device *hdev = ps_dev->hdev; + struct dualsense *ds = container_of(ps_dev, struct dualsense, base); + struct dualsense_input_report *ds_report; + uint8_t value; + + /* + * dualsense in usb uses the full hid report for reportid 1, but + * bluetooth uses a minimal hid report for reportid 1 and reports + * the full report using reportid 49. + */ + if (hdev->bus == bus_usb && report->id == ds_input_report_usb && + size == ds_input_report_usb_size) { + ds_report = (struct dualsense_input_report *)&data[1]; + } else { + hid_err(hdev, "unhandled reportid=%d ", report->id); + return -1; + } + + input_report_abs(ds->gamepad, abs_x, ds_report->x); + input_report_abs(ds->gamepad, abs_y, ds_report->y); + input_report_abs(ds->gamepad, abs_rx, ds_report->rx); + input_report_abs(ds->gamepad, abs_ry, ds_report->ry); + input_report_abs(ds->gamepad, abs_z, ds_report->z); + input_report_abs(ds->gamepad, abs_rz, ds_report->rz); + + value = ds_report->buttons[0] & ds_buttons0_hat_switch; + if (value > array_size(ps_gamepad_hat_mapping)) + value = 8; /* center */ + input_report_abs(ds->gamepad, abs_hat0x, ps_gamepad_hat_mapping[value].x); + input_report_abs(ds->gamepad, abs_hat0y, ps_gamepad_hat_mapping[value].y); + + input_report_key(ds->gamepad, btn_west, ds_report->buttons[0] & ds_buttons0_square); + input_report_key(ds->gamepad, btn_south, ds_report->buttons[0] & ds_buttons0_cross); + input_report_key(ds->gamepad, btn_east, ds_report->buttons[0] & ds_buttons0_circle); + input_report_key(ds->gamepad, btn_north, ds_report->buttons[0] & ds_buttons0_triangle); + input_report_key(ds->gamepad, btn_tl, ds_report->buttons[1] & ds_buttons1_l1); + input_report_key(ds->gamepad, btn_tr, ds_report->buttons[1] & ds_buttons1_r1); + input_report_key(ds->gamepad, btn_tl2, ds_report->buttons[1] & ds_buttons1_l2); + input_report_key(ds->gamepad, btn_tr2, ds_report->buttons[1] & ds_buttons1_r2); + input_report_key(ds->gamepad, btn_select, ds_report->buttons[1] & ds_buttons1_create); + input_report_key(ds->gamepad, btn_start, ds_report->buttons[1] & ds_buttons1_options); + input_report_key(ds->gamepad, btn_thumbl, ds_report->buttons[1] & ds_buttons1_l3); + input_report_key(ds->gamepad, btn_thumbr, ds_report->buttons[1] & ds_buttons1_r3); + input_report_key(ds->gamepad, btn_mode, ds_report->buttons[2] & ds_buttons2_ps_home); + input_sync(ds->gamepad); + + return 0; +} + +static struct ps_device *dualsense_create(struct hid_device *hdev) +{ + struct dualsense *ds; + int ret; + + ds = devm_kzalloc(&hdev->dev, sizeof(*ds), gfp_kernel); + if (!ds) + return err_ptr(-enomem); + + /* + * patch version to allow userspace to distinguish between + * hid-generic vs hid-playstation axis and button mapping. + */ + hdev->version |= hid_playstation_version_patch; + + ds->base.hdev = hdev; + ds->base.parse_report = dualsense_parse_report; + hid_set_drvdata(hdev, ds); + + ds->gamepad = ps_gamepad_create(hdev); + if (is_err(ds->gamepad)) { + ret = ptr_err(ds->gamepad); + goto err; + } + + return &ds->base; + +err: + return err_ptr(ret); +} + +static int ps_raw_event(struct hid_device *hdev, struct hid_report *report, + u8 *data, int size) +{ + struct ps_device *dev = hid_get_drvdata(hdev); + + if (dev && dev->parse_report) + return dev->parse_report(dev, report, data, size); + + return 0; +} + +static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + struct ps_device *dev; + int ret; + + ret = hid_parse(hdev); + if (ret) { + hid_err(hdev, "parse failed "); + return ret; + } + + ret = hid_hw_start(hdev, hid_connect_hidraw); + if (ret) { + hid_err(hdev, "failed to start hid device "); + return ret; + } + + ret = hid_hw_open(hdev); + if (ret) { + hid_err(hdev, "failed to open hid device "); + goto err_stop; + } + + if (hdev->product == usb_device_id_sony_ps5_controller) { + dev = dualsense_create(hdev); + if (is_err(dev)) { + hid_err(hdev, "failed to create dualsense. "); + ret = ptr_err(dev); + goto err_close; + } + } + + return ret; + +err_close: + hid_hw_close(hdev); +err_stop: + hid_hw_stop(hdev); + return ret; +} + +static void ps_remove(struct hid_device *hdev) +{ + hid_hw_close(hdev); + hid_hw_stop(hdev); +} + +static const struct hid_device_id ps_devices[] = { + { hid_usb_device(usb_vendor_id_sony, usb_device_id_sony_ps5_controller) }, + { } +}; +module_device_table(hid, ps_devices); + +static struct hid_driver ps_driver = { + .name = "playstation", + .id_table = ps_devices, + .probe = ps_probe, + .remove = ps_remove, + .raw_event = ps_raw_event, +}; + +module_hid_driver(ps_driver); + +module_author("sony interactive entertainment"); +module_description("hid driver for playstation peripherals."); +module_license("gpl");
Tablets, touch screens, keyboards, mouses
bc2e15a9a0228b10fece576d4f6a974c002ff07b
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: use dualsense mac address as unique identifier.
use the dualsense mac address as a unique identifier for the hid device.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['c']
1
58
0
--- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c + uint8_t mac_address[6]; /* note: stored in little endian order. */ +#define ds_feature_report_pairing_info 0x09 +#define ds_feature_report_pairing_info_size 20 + +static int ps_get_report(struct hid_device *hdev, uint8_t report_id, uint8_t *buf, size_t size) +{ + int ret; + + ret = hid_hw_raw_request(hdev, report_id, buf, size, hid_feature_report, + hid_req_get_report); + if (ret < 0) { + hid_err(hdev, "failed to retrieve feature with reportid %d: %d ", report_id, ret); + return ret; + } + + if (ret != size) { + hid_err(hdev, "invalid byte count transferred, expected %zu got %d ", size, ret); + return -einval; + } + + if (buf[0] != report_id) { + hid_err(hdev, "invalid reportid received, expected %d got %d ", report_id, buf[0]); + return -einval; + } + + return 0; +} + +static int dualsense_get_mac_address(struct dualsense *ds) +{ + uint8_t *buf; + int ret = 0; + + buf = kzalloc(ds_feature_report_pairing_info_size, gfp_kernel); + if (!buf) + return -enomem; + + ret = ps_get_report(ds->base.hdev, ds_feature_report_pairing_info, buf, + ds_feature_report_pairing_info_size); + if (ret) { + hid_err(ds->base.hdev, "failed to retrieve dualsense pairing info: %d ", ret); + goto err_free; + } + + memcpy(ds->base.mac_address, &buf[1], sizeof(ds->base.mac_address)); + +err_free: + kfree(buf); + return ret; +} + + ret = dualsense_get_mac_address(ds); + if (ret) { + hid_err(hdev, "failed to get mac address from dualsense "); + return err_ptr(ret); + } + snprintf(hdev->uniq, sizeof(hdev->uniq), "%pmr", ds->base.mac_address); +
Tablets, touch screens, keyboards, mouses
b99dcefd78ff13349ce5c8641605d1de3d638ea0
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: add dualsense battery support.
report dualsense battery status information through power_supply class.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['kconfig', 'c']
2
138
3
--- diff --git a/drivers/hid/kconfig b/drivers/hid/kconfig --- a/drivers/hid/kconfig +++ b/drivers/hid/kconfig + select power_supply diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c + spinlock_t lock; + + struct power_supply_desc battery_desc; + struct power_supply *battery; + uint8_t battery_capacity; + int battery_status; + +/* status field of dualsense input report. */ +#define ds_status_battery_capacity genmask(3, 0) +#define ds_status_charging genmask(7, 4) +#define ds_status_charging_shift 4 + +static enum power_supply_property ps_power_supply_props[] = { + power_supply_prop_status, + power_supply_prop_present, + power_supply_prop_capacity, + power_supply_prop_scope, +}; + +static int ps_battery_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct ps_device *dev = power_supply_get_drvdata(psy); + uint8_t battery_capacity; + int battery_status; + unsigned long flags; + int ret; + + spin_lock_irqsave(&dev->lock, flags); + battery_capacity = dev->battery_capacity; + battery_status = dev->battery_status; + spin_unlock_irqrestore(&dev->lock, flags); + + switch (psp) { + case power_supply_prop_status: + val->intval = battery_status; + break; + case power_supply_prop_present: + val->intval = 1; + break; + case power_supply_prop_capacity: + val->intval = battery_capacity; + break; + case power_supply_prop_scope: + val->intval = power_supply_scope_device; + break; + default: + ret = -einval; + break; + } + + return 0; +} + +static int ps_device_register_battery(struct ps_device *dev) +{ + struct power_supply *battery; + struct power_supply_config battery_cfg = { .drv_data = dev }; + int ret; + + dev->battery_desc.type = power_supply_type_battery; + dev->battery_desc.properties = ps_power_supply_props; + dev->battery_desc.num_properties = array_size(ps_power_supply_props); + dev->battery_desc.get_property = ps_battery_get_property; + dev->battery_desc.name = devm_kasprintf(&dev->hdev->dev, gfp_kernel, + "ps-controller-battery-%pmr", dev->mac_address); + if (!dev->battery_desc.name) + return -enomem; + + battery = devm_power_supply_register(&dev->hdev->dev, &dev->battery_desc, &battery_cfg); + if (is_err(battery)) { + ret = ptr_err(battery); + hid_err(dev->hdev, "unable to register battery device: %d ", ret); + return ret; + } + dev->battery = battery; + + ret = power_supply_powers(dev->battery, &dev->hdev->dev); + if (ret) { + hid_err(dev->hdev, "unable to activate battery device: %d ", ret); + return ret; + } + + return 0; +} + - uint8_t value; + uint8_t battery_data, battery_capacity, charging_status, value; + int battery_status; + unsigned long flags; + battery_data = ds_report->status & ds_status_battery_capacity; + charging_status = (ds_report->status & ds_status_charging) >> ds_status_charging_shift; + + switch (charging_status) { + case 0x0: + /* + * each unit of battery data corresponds to 10% + * 0 = 0-9%, 1 = 10-19%, .. and 10 = 100% + */ + battery_capacity = min(battery_data * 10 + 5, 100); + battery_status = power_supply_status_discharging; + break; + case 0x1: + battery_capacity = min(battery_data * 10 + 5, 100); + battery_status = power_supply_status_charging; + break; + case 0x2: + battery_capacity = 100; + battery_status = power_supply_status_full; + break; + case 0xa: /* voltage or temperature out of range */ + case 0xb: /* temperature error */ + battery_capacity = 0; + battery_status = power_supply_status_not_charging; + break; + case 0xf: /* charging error */ + default: + battery_capacity = 0; + battery_status = power_supply_status_unknown; + } + + spin_lock_irqsave(&ps_dev->lock, flags); + ps_dev->battery_capacity = battery_capacity; + ps_dev->battery_status = battery_status; + spin_unlock_irqrestore(&ps_dev->lock, flags); + + struct ps_device *ps_dev; - ds->base.hdev = hdev; - ds->base.parse_report = dualsense_parse_report; + ps_dev = &ds->base; + ps_dev->hdev = hdev; + spin_lock_init(&ps_dev->lock); + ps_dev->battery_capacity = 100; /* initial value until parse_report. */ + ps_dev->battery_status = power_supply_status_unknown; + ps_dev->parse_report = dualsense_parse_report; + ret = ps_device_register_battery(ps_dev); + if (ret) + goto err; +
Tablets, touch screens, keyboards, mouses
d30bca44809eb1d2937e59d3d09694f40613070d
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: add dualsense touchpad support.
implement support for dualsense touchpad as a separate input device.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['c']
1
66
0
--- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +/* + * status of a dualsense touch point contact. + * contact ids, with highest bit set are 'inactive' + * and any associated data is then invalid. + */ +#define ds_touch_point_inactive bit(7) + +/* dualsense hardware limits */ +#define ds_touchpad_width 1920 +#define ds_touchpad_height 1080 + + struct input_dev *touchpad; +static struct input_dev *ps_touchpad_create(struct hid_device *hdev, int width, int height, + unsigned int num_contacts) +{ + struct input_dev *touchpad; + int ret; + + touchpad = ps_allocate_input_dev(hdev, "touchpad"); + if (is_err(touchpad)) + return err_cast(touchpad); + + /* map button underneath touchpad to btn_left. */ + input_set_capability(touchpad, ev_key, btn_left); + __set_bit(input_prop_buttonpad, touchpad->propbit); + + input_set_abs_params(touchpad, abs_mt_position_x, 0, width - 1, 0, 0); + input_set_abs_params(touchpad, abs_mt_position_y, 0, height - 1, 0, 0); + + ret = input_mt_init_slots(touchpad, num_contacts, input_mt_pointer); + if (ret) + return err_ptr(ret); + + ret = input_register_device(touchpad); + if (ret) + return err_ptr(ret); + + return touchpad; +} + + int i; + for (i = 0; i < array_size(ds_report->points); i++) { + struct dualsense_touch_point *point = &ds_report->points[i]; + bool active = (point->contact & ds_touch_point_inactive) ? false : true; + + input_mt_slot(ds->touchpad, i); + input_mt_report_slot_state(ds->touchpad, mt_tool_finger, active); + + if (active) { + int x = (point->x_hi << 8) | point->x_lo; + int y = (point->y_hi << 4) | point->y_lo; + + input_report_abs(ds->touchpad, abs_mt_position_x, x); + input_report_abs(ds->touchpad, abs_mt_position_y, y); + } + } + input_mt_sync_frame(ds->touchpad); + input_report_key(ds->touchpad, btn_left, ds_report->buttons[2] & ds_buttons2_touchpad); + input_sync(ds->touchpad); + + ds->touchpad = ps_touchpad_create(hdev, ds_touchpad_width, ds_touchpad_height, 2); + if (is_err(ds->touchpad)) { + ret = ptr_err(ds->touchpad); + goto err; + } +
Tablets, touch screens, keyboards, mouses
f6bb05fcb2a10ff26ac5af1c29066d42019dc464
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: add dualsense accelerometer and gyroscope support.
the dualsense features an accelerometer and gyroscope. the data is embedded into the main hid input reports. expose both sensors through through a separate evdev node.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['c']
1
203
0
--- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +/* calibration data for playstation motion sensors. */ +struct ps_calibration_data { + int abs_code; + short bias; + int sens_numer; + int sens_denom; +}; + +#define ds_feature_report_calibration 0x05 +#define ds_feature_report_calibration_size 41 +#define ds_acc_res_per_g 8192 +#define ds_acc_range (4*ds_acc_res_per_g) +#define ds_gyro_res_per_deg_s 1024 +#define ds_gyro_range (2048*ds_gyro_res_per_deg_s) + struct input_dev *sensors; + + /* calibration data for accelerometer and gyroscope. */ + struct ps_calibration_data accel_calib_data[3]; + struct ps_calibration_data gyro_calib_data[3]; + + /* timestamp for sensor data */ + bool sensor_timestamp_initialized; + uint32_t prev_sensor_timestamp; + uint32_t sensor_timestamp_us; +static struct input_dev *ps_sensors_create(struct hid_device *hdev, int accel_range, int accel_res, + int gyro_range, int gyro_res) +{ + struct input_dev *sensors; + int ret; + + sensors = ps_allocate_input_dev(hdev, "motion sensors"); + if (is_err(sensors)) + return err_cast(sensors); + + __set_bit(input_prop_accelerometer, sensors->propbit); + __set_bit(ev_msc, sensors->evbit); + __set_bit(msc_timestamp, sensors->mscbit); + + /* accelerometer */ + input_set_abs_params(sensors, abs_x, -accel_range, accel_range, 16, 0); + input_set_abs_params(sensors, abs_y, -accel_range, accel_range, 16, 0); + input_set_abs_params(sensors, abs_z, -accel_range, accel_range, 16, 0); + input_abs_set_res(sensors, abs_x, accel_res); + input_abs_set_res(sensors, abs_y, accel_res); + input_abs_set_res(sensors, abs_z, accel_res); + + /* gyroscope */ + input_set_abs_params(sensors, abs_rx, -gyro_range, gyro_range, 16, 0); + input_set_abs_params(sensors, abs_ry, -gyro_range, gyro_range, 16, 0); + input_set_abs_params(sensors, abs_rz, -gyro_range, gyro_range, 16, 0); + input_abs_set_res(sensors, abs_rx, gyro_res); + input_abs_set_res(sensors, abs_ry, gyro_res); + input_abs_set_res(sensors, abs_rz, gyro_res); + + ret = input_register_device(sensors); + if (ret) + return err_ptr(ret); + + return sensors; +} + +static int dualsense_get_calibration_data(struct dualsense *ds) +{ + short gyro_pitch_bias, gyro_pitch_plus, gyro_pitch_minus; + short gyro_yaw_bias, gyro_yaw_plus, gyro_yaw_minus; + short gyro_roll_bias, gyro_roll_plus, gyro_roll_minus; + short gyro_speed_plus, gyro_speed_minus; + short acc_x_plus, acc_x_minus; + short acc_y_plus, acc_y_minus; + short acc_z_plus, acc_z_minus; + int speed_2x; + int range_2g; + int ret = 0; + uint8_t *buf; + + buf = kzalloc(ds_feature_report_calibration_size, gfp_kernel); + if (!buf) + return -enomem; + + ret = ps_get_report(ds->base.hdev, ds_feature_report_calibration, buf, + ds_feature_report_calibration_size); + if (ret) { + hid_err(ds->base.hdev, "failed to retrieve dualsense calibration info: %d ", ret); + goto err_free; + } + + gyro_pitch_bias = get_unaligned_le16(&buf[1]); + gyro_yaw_bias = get_unaligned_le16(&buf[3]); + gyro_roll_bias = get_unaligned_le16(&buf[5]); + gyro_pitch_plus = get_unaligned_le16(&buf[7]); + gyro_pitch_minus = get_unaligned_le16(&buf[9]); + gyro_yaw_plus = get_unaligned_le16(&buf[11]); + gyro_yaw_minus = get_unaligned_le16(&buf[13]); + gyro_roll_plus = get_unaligned_le16(&buf[15]); + gyro_roll_minus = get_unaligned_le16(&buf[17]); + gyro_speed_plus = get_unaligned_le16(&buf[19]); + gyro_speed_minus = get_unaligned_le16(&buf[21]); + acc_x_plus = get_unaligned_le16(&buf[23]); + acc_x_minus = get_unaligned_le16(&buf[25]); + acc_y_plus = get_unaligned_le16(&buf[27]); + acc_y_minus = get_unaligned_le16(&buf[29]); + acc_z_plus = get_unaligned_le16(&buf[31]); + acc_z_minus = get_unaligned_le16(&buf[33]); + + /* + * set gyroscope calibration and normalization parameters. + * data values will be normalized to 1/ds_gyro_res_per_deg_s degree/s. + */ + speed_2x = (gyro_speed_plus + gyro_speed_minus); + ds->gyro_calib_data[0].abs_code = abs_rx; + ds->gyro_calib_data[0].bias = gyro_pitch_bias; + ds->gyro_calib_data[0].sens_numer = speed_2x*ds_gyro_res_per_deg_s; + ds->gyro_calib_data[0].sens_denom = gyro_pitch_plus - gyro_pitch_minus; + + ds->gyro_calib_data[1].abs_code = abs_ry; + ds->gyro_calib_data[1].bias = gyro_yaw_bias; + ds->gyro_calib_data[1].sens_numer = speed_2x*ds_gyro_res_per_deg_s; + ds->gyro_calib_data[1].sens_denom = gyro_yaw_plus - gyro_yaw_minus; + + ds->gyro_calib_data[2].abs_code = abs_rz; + ds->gyro_calib_data[2].bias = gyro_roll_bias; + ds->gyro_calib_data[2].sens_numer = speed_2x*ds_gyro_res_per_deg_s; + ds->gyro_calib_data[2].sens_denom = gyro_roll_plus - gyro_roll_minus; + + /* + * set accelerometer calibration and normalization parameters. + * data values will be normalized to 1/ds_acc_res_per_g g. + */ + range_2g = acc_x_plus - acc_x_minus; + ds->accel_calib_data[0].abs_code = abs_x; + ds->accel_calib_data[0].bias = acc_x_plus - range_2g / 2; + ds->accel_calib_data[0].sens_numer = 2*ds_acc_res_per_g; + ds->accel_calib_data[0].sens_denom = range_2g; + + range_2g = acc_y_plus - acc_y_minus; + ds->accel_calib_data[1].abs_code = abs_y; + ds->accel_calib_data[1].bias = acc_y_plus - range_2g / 2; + ds->accel_calib_data[1].sens_numer = 2*ds_acc_res_per_g; + ds->accel_calib_data[1].sens_denom = range_2g; + + range_2g = acc_z_plus - acc_z_minus; + ds->accel_calib_data[2].abs_code = abs_z; + ds->accel_calib_data[2].bias = acc_z_plus - range_2g / 2; + ds->accel_calib_data[2].sens_numer = 2*ds_acc_res_per_g; + ds->accel_calib_data[2].sens_denom = range_2g; + +err_free: + kfree(buf); + return ret; +} + + uint32_t sensor_timestamp; + /* parse and calibrate gyroscope data. */ + for (i = 0; i < array_size(ds_report->gyro); i++) { + int raw_data = (short)le16_to_cpu(ds_report->gyro[i]); + int calib_data = mult_frac(ds->gyro_calib_data[i].sens_numer, + raw_data - ds->gyro_calib_data[i].bias, + ds->gyro_calib_data[i].sens_denom); + + input_report_abs(ds->sensors, ds->gyro_calib_data[i].abs_code, calib_data); + } + + /* parse and calibrate accelerometer data. */ + for (i = 0; i < array_size(ds_report->accel); i++) { + int raw_data = (short)le16_to_cpu(ds_report->accel[i]); + int calib_data = mult_frac(ds->accel_calib_data[i].sens_numer, + raw_data - ds->accel_calib_data[i].bias, + ds->accel_calib_data[i].sens_denom); + + input_report_abs(ds->sensors, ds->accel_calib_data[i].abs_code, calib_data); + } + + /* convert timestamp (in 0.33us unit) to timestamp_us */ + sensor_timestamp = le32_to_cpu(ds_report->sensor_timestamp); + if (!ds->sensor_timestamp_initialized) { + ds->sensor_timestamp_us = div_round_closest(sensor_timestamp, 3); + ds->sensor_timestamp_initialized = true; + } else { + uint32_t delta; + + if (ds->prev_sensor_timestamp > sensor_timestamp) + delta = (u32_max - ds->prev_sensor_timestamp + sensor_timestamp + 1); + else + delta = sensor_timestamp - ds->prev_sensor_timestamp; + ds->sensor_timestamp_us += div_round_closest(delta, 3); + } + ds->prev_sensor_timestamp = sensor_timestamp; + input_event(ds->sensors, ev_msc, msc_timestamp, ds->sensor_timestamp_us); + input_sync(ds->sensors); + + ret = dualsense_get_calibration_data(ds); + if (ret) { + hid_err(hdev, "failed to get calibration data from dualsense "); + goto err; + } + + ds->sensors = ps_sensors_create(hdev, ds_acc_range, ds_acc_res_per_g, + ds_gyro_range, ds_gyro_res_per_deg_s); + if (is_err(ds->sensors)) { + ret = ptr_err(ds->sensors); + goto err; + } +
Tablets, touch screens, keyboards, mouses
402987c5d98a9dd0d611cfe3af5e5bdc13d122d0
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: track devices in list.
track devices in a list, so we can detect when a device is connected twice when using bluetooth and usb.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['c']
1
46
0
--- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +/* list of connected playstation devices. */ +static define_mutex(ps_devices_lock); +static list_head(ps_devices_list); + + struct list_head list; +/* + * add a new ps_device to ps_devices if it doesn't exist. + * return error on duplicate device, which can happen if the same + * device is connected using both bluetooth and usb. + */ +static int ps_devices_list_add(struct ps_device *dev) +{ + struct ps_device *entry; + + mutex_lock(&ps_devices_lock); + list_for_each_entry(entry, &ps_devices_list, list) { + if (!memcmp(entry->mac_address, dev->mac_address, sizeof(dev->mac_address))) { + hid_err(dev->hdev, "duplicate device found for mac address %pmr. ", + dev->mac_address); + mutex_unlock(&ps_devices_lock); + return -eexist; + } + } + + list_add_tail(&dev->list, &ps_devices_list); + mutex_unlock(&ps_devices_lock); + return 0; +} + +static int ps_devices_list_remove(struct ps_device *dev) +{ + mutex_lock(&ps_devices_lock); + list_del(&dev->list); + mutex_unlock(&ps_devices_lock); + return 0; +} + + ret = ps_devices_list_add(ps_dev); + if (ret) + return err_ptr(ret); + + ps_devices_list_remove(ps_dev); + struct ps_device *dev = hid_get_drvdata(hdev); + + ps_devices_list_remove(dev); +
Tablets, touch screens, keyboards, mouses
53f04e83577c5e146eeee1a671efeb58db14afd1
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: add dualsense bluetooth support.
this patch adds support for the dualsense when operating in bluetooth mode. the device has the same behavior as the dualshock 4 in that by default it sends a limited input report (0x1), but after requesting calibration data, it switches to an extended input report (report 49), which adds data for touchpad, motion sensors, battery and more.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['kconfig', 'c']
2
42
0
--- diff --git a/drivers/hid/kconfig b/drivers/hid/kconfig --- a/drivers/hid/kconfig +++ b/drivers/hid/kconfig + select crc32 diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +#include <linux/crc32.h> +/* seed values for dualshock4 / dualsense crc32 for different report types. */ +#define ps_input_crc32_seed 0xa1 +#define ps_feature_crc32_seed 0xa3 + +#define ds_input_report_bt 0x31 +#define ds_input_report_bt_size 78 +/* compute crc32 of hid data and compare against expected crc. */ +static bool ps_check_crc32(uint8_t seed, uint8_t *data, size_t len, uint32_t report_crc) +{ + uint32_t crc; + + crc = crc32_le(0xffffffff, &seed, 1); + crc = ~crc32_le(crc, data, len); + + return crc == report_crc; +} + + if (hdev->bus == bus_bluetooth) { + /* last 4 bytes contains crc32. */ + uint8_t crc_offset = size - 4; + uint32_t report_crc = get_unaligned_le32(&buf[crc_offset]); + + if (!ps_check_crc32(ps_feature_crc32_seed, buf, crc_offset, report_crc)) { + hid_err(hdev, "crc check failed for reportid=%d ", report_id); + return -eilseq; + } + } + + } else if (hdev->bus == bus_bluetooth && report->id == ds_input_report_bt && + size == ds_input_report_bt_size) { + /* last 4 bytes of input report contain crc32 */ + uint32_t report_crc = get_unaligned_le32(&data[size - 4]); + + if (!ps_check_crc32(ps_input_crc32_seed, data, size - 4, report_crc)) { + hid_err(hdev, "dualsense input crc's check failed "); + return -eilseq; + } + + ds_report = (struct dualsense_input_report *)&data[2]; + { hid_bluetooth_device(usb_vendor_id_sony, usb_device_id_sony_ps5_controller) },
Tablets, touch screens, keyboards, mouses
799b2b533a299ba5b64ddd22639836c2a5eaee31
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: add dualsense classic rumble support.
the dualsense features a haptics system based on voicecoil motors, which requires pcm data (or special hid packets using bluetooth). there is no appropriate api yet in the linux kernel to expose these. the controller also provides a classic rumble feature for backwards compatibility. expose this classic rumble feature using the ff framework.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['kconfig', 'c']
2
214
2
--- diff --git a/drivers/hid/kconfig b/drivers/hid/kconfig --- a/drivers/hid/kconfig +++ b/drivers/hid/kconfig +config playstation_ff + bool "playstation force feedback support" + depends on hid_playstation + select input_ff_memless + help + say y here if you would like to enable force feedback support for + playstation game controllers. + diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +#define ps_output_crc32_seed 0xa2 +#define ds_output_report_usb 0x02 +#define ds_output_report_usb_size 63 +#define ds_output_report_bt 0x31 +#define ds_output_report_bt_size 78 + /* magic value required in tag field of bluetooth output report. */ +#define ds_output_tag 0x10 +/* flags for dualsense output report. */ +#define ds_output_valid_flag0_compatible_vibration bit(0) +#define ds_output_valid_flag0_haptics_select bit(1) + + + /* compatible rumble state */ + bool update_rumble; + uint8_t motor_left; + uint8_t motor_right; + + struct work_struct output_worker; + void *output_report_dmabuf; + uint8_t output_seq; /* sequence number for output report. */ +/* common data between dualsense bt/usb main output report. */ +struct dualsense_output_report_common { + uint8_t valid_flag0; + uint8_t valid_flag1; + + /* for dualshock 4 compatibility mode. */ + uint8_t motor_right; + uint8_t motor_left; + + /* audio controls */ + uint8_t reserved[4]; + uint8_t mute_button_led; + + uint8_t power_save_control; + uint8_t reserved2[28]; + + /* leds and lightbar */ + uint8_t valid_flag2; + uint8_t reserved3[2]; + uint8_t lightbar_setup; + uint8_t led_brightness; + uint8_t player_leds; + uint8_t lightbar_red; + uint8_t lightbar_green; + uint8_t lightbar_blue; +} __packed; +static_assert(sizeof(struct dualsense_output_report_common) == 47); + +struct dualsense_output_report_bt { + uint8_t report_id; /* 0x31 */ + uint8_t seq_tag; + uint8_t tag; + struct dualsense_output_report_common common; + uint8_t reserved[24]; + __le32 crc32; +} __packed; +static_assert(sizeof(struct dualsense_output_report_bt) == ds_output_report_bt_size); + +struct dualsense_output_report_usb { + uint8_t report_id; /* 0x02 */ + struct dualsense_output_report_common common; + uint8_t reserved[15]; +} __packed; +static_assert(sizeof(struct dualsense_output_report_usb) == ds_output_report_usb_size); + +/* + * the dualsense has a main output report used to control most features. it is + * largely the same between bluetooth and usb except for different headers and crc. + * this structure hide the differences between the two to simplify sending output reports. + */ +struct dualsense_output_report { + uint8_t *data; /* start of data */ + uint8_t len; /* size of output report */ + + /* points to bluetooth data payload in case for a bluetooth report else null. */ + struct dualsense_output_report_bt *bt; + /* points to usb data payload in case for a usb report else null. */ + struct dualsense_output_report_usb *usb; + /* points to common section of report, so past any headers. */ + struct dualsense_output_report_common *common; +}; + -static struct input_dev *ps_gamepad_create(struct hid_device *hdev) +static struct input_dev *ps_gamepad_create(struct hid_device *hdev, + int (*play_effect)(struct input_dev *, void *, struct ff_effect *)) +#if is_enabled(config_playstation_ff) + if (play_effect) { + input_set_capability(gamepad, ev_ff, ff_rumble); + input_ff_create_memless(gamepad, null, play_effect); + } +#endif + +static void dualsense_init_output_report(struct dualsense *ds, struct dualsense_output_report *rp, + void *buf) +{ + struct hid_device *hdev = ds->base.hdev; + + if (hdev->bus == bus_bluetooth) { + struct dualsense_output_report_bt *bt = buf; + + memset(bt, 0, sizeof(*bt)); + bt->report_id = ds_output_report_bt; + bt->tag = ds_output_tag; /* tag must be set. exact meaning is unclear. */ + + /* + * highest 4-bit is a sequence number, which needs to be increased + * every report. lowest 4-bit is tag and can be zero for now. + */ + bt->seq_tag = (ds->output_seq << 4) | 0x0; + if (++ds->output_seq == 16) + ds->output_seq = 0; + + rp->data = buf; + rp->len = sizeof(*bt); + rp->bt = bt; + rp->usb = null; + rp->common = &bt->common; + } else { /* usb */ + struct dualsense_output_report_usb *usb = buf; + + memset(usb, 0, sizeof(*usb)); + usb->report_id = ds_output_report_usb; + + rp->data = buf; + rp->len = sizeof(*usb); + rp->bt = null; + rp->usb = usb; + rp->common = &usb->common; + } +} + +/* + * helper function to send dualsense output reports. applies a crc at the end of a report + * for bluetooth reports. + */ +static void dualsense_send_output_report(struct dualsense *ds, + struct dualsense_output_report *report) +{ + struct hid_device *hdev = ds->base.hdev; + + /* bluetooth packets need to be signed with a crc in the last 4 bytes. */ + if (report->bt) { + uint32_t crc; + uint8_t seed = ps_output_crc32_seed; + + crc = crc32_le(0xffffffff, &seed, 1); + crc = ~crc32_le(crc, report->data, report->len - 4); + + report->bt->crc32 = cpu_to_le32(crc); + } + + hid_hw_output_report(hdev, report->data, report->len); +} + +static void dualsense_output_worker(struct work_struct *work) +{ + struct dualsense *ds = container_of(work, struct dualsense, output_worker); + struct dualsense_output_report report; + struct dualsense_output_report_common *common; + unsigned long flags; + + dualsense_init_output_report(ds, &report, ds->output_report_dmabuf); + common = report.common; + + spin_lock_irqsave(&ds->base.lock, flags); + + if (ds->update_rumble) { + /* select classic rumble style haptics and enable it. */ + common->valid_flag0 |= ds_output_valid_flag0_haptics_select; + common->valid_flag0 |= ds_output_valid_flag0_compatible_vibration; + common->motor_left = ds->motor_left; + common->motor_right = ds->motor_right; + ds->update_rumble = false; + } + + spin_unlock_irqrestore(&ds->base.lock, flags); + + dualsense_send_output_report(ds, &report); +} + +static int dualsense_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) +{ + struct hid_device *hdev = input_get_drvdata(dev); + struct dualsense *ds = hid_get_drvdata(hdev); + unsigned long flags; + + if (effect->type != ff_rumble) + return 0; + + spin_lock_irqsave(&ds->base.lock, flags); + ds->update_rumble = true; + ds->motor_left = effect->u.rumble.strong_magnitude / 256; + ds->motor_right = effect->u.rumble.weak_magnitude / 256; + spin_unlock_irqrestore(&ds->base.lock, flags); + + schedule_work(&ds->output_worker); + return 0; +} + + uint8_t max_output_report_size; + init_work(&ds->output_worker, dualsense_output_worker); + max_output_report_size = sizeof(struct dualsense_output_report_bt); + ds->output_report_dmabuf = devm_kzalloc(&hdev->dev, max_output_report_size, gfp_kernel); + if (!ds->output_report_dmabuf) + return err_ptr(-enomem); + - ds->gamepad = ps_gamepad_create(hdev); + ds->gamepad = ps_gamepad_create(hdev, dualsense_play_effect);
Tablets, touch screens, keyboards, mouses
51151098d7ab832f2a8b8f5c51fe224a9c98fdd5
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: report dualsense hardware and firmware version.
retrieve dualsense hardware and firmware information using a vendor specific feature report. report the data through sysfs and also report using hid_info as there can be signficant differences between versions.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
new driver for ps5 'dualsense' controller
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ']
['c']
1
81
0
--- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c + uint32_t hw_version; + uint32_t fw_version; +#define ds_feature_report_firmware_info 0x20 +#define ds_feature_report_firmware_info_size 64 +static ssize_t firmware_version_show(struct device *dev, + struct device_attribute + *attr, char *buf) +{ + struct hid_device *hdev = to_hid_device(dev); + struct ps_device *ps_dev = hid_get_drvdata(hdev); + + return sysfs_emit(buf, "0x%08x ", ps_dev->fw_version); +} + +static device_attr_ro(firmware_version); + +static ssize_t hardware_version_show(struct device *dev, + struct device_attribute + *attr, char *buf) +{ + struct hid_device *hdev = to_hid_device(dev); + struct ps_device *ps_dev = hid_get_drvdata(hdev); + + return sysfs_emit(buf, "0x%08x ", ps_dev->hw_version); +} + +static device_attr_ro(hardware_version); + +static struct attribute *ps_device_attributes[] = { + &dev_attr_firmware_version.attr, + &dev_attr_hardware_version.attr, + null +}; + +static const struct attribute_group ps_device_attribute_group = { + .attrs = ps_device_attributes, +}; + +static int dualsense_get_firmware_info(struct dualsense *ds) +{ + uint8_t *buf; + int ret; + + buf = kzalloc(ds_feature_report_firmware_info_size, gfp_kernel); + if (!buf) + return -enomem; + + ret = ps_get_report(ds->base.hdev, ds_feature_report_firmware_info, buf, + ds_feature_report_firmware_info_size); + if (ret) { + hid_err(ds->base.hdev, "failed to retrieve dualsense firmware info: %d ", ret); + goto err_free; + } + + ds->base.hw_version = get_unaligned_le32(&buf[24]); + ds->base.fw_version = get_unaligned_le32(&buf[28]); + +err_free: + kfree(buf); + return ret; +} + + ret = dualsense_get_firmware_info(ds); + if (ret) { + hid_err(hdev, "failed to get firmware info from dualsense "); + return err_ptr(ret); + } + + /* + * reporting hardware and firmware is important as there are frequent updates, which + * can change behavior. + */ + hid_info(hdev, "registered dualsense controller hw_version=0x%08x fw_version=0x%08x ", + ds->base.hw_version, ds->base.fw_version); + + ret = devm_device_add_group(&hdev->dev, &ps_device_attribute_group); + if (ret) { + hid_err(hdev, "failed to register sysfs nodes. "); + goto err_close; + } +
Tablets, touch screens, keyboards, mouses
0b25b55d34f554b43a679e7e1303beb973b63e27
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: add dualsense player led support.
the dualsense features 5 player leds below its touchpad, which are meant as player id indications. the leds are configured with a player id determined by an id allocator, which assign player ids to ps_device instances.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add dualsense player led support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'playstation']
['c']
1
82
1
- hid: playstation: add dualsense player leds support. - hid: playstation: dualsense set leds to default player id. --- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +#include <linux/idr.h> +static define_ida(ps_player_id_allocator); + + uint32_t player_id; + +#define ds_output_valid_flag1_player_indicator_control_enable bit(4) + /* player leds */ + bool update_player_leds; + uint8_t player_leds_state; + struct led_classdev player_leds[5]; + +static int ps_device_set_player_id(struct ps_device *dev) +{ + int ret = ida_alloc(&ps_player_id_allocator, gfp_kernel); + + if (ret < 0) + return ret; + + dev->player_id = ret; + return 0; +} + +static void ps_device_release_player_id(struct ps_device *dev) +{ + ida_free(&ps_player_id_allocator, dev->player_id); + + dev->player_id = u32_max; +} + + if (ds->update_player_leds) { + common->valid_flag1 |= ds_output_valid_flag1_player_indicator_control_enable; + common->player_leds = ds->player_leds_state; + + ds->update_player_leds = false; + } + +static void dualsense_set_player_leds(struct dualsense *ds) +{ + /* + * the dualsense controller has a row of 5 leds used for player ids. + * behavior on the playstation 5 console is to center the player id + * across the leds, so e.g. player 1 would be "--x--" with x being 'on'. + * follow a similar mapping here. + */ + static const int player_ids[5] = { + bit(2), + bit(3) | bit(1), + bit(4) | bit(2) | bit(0), + bit(4) | bit(3) | bit(1) | bit(0), + bit(4) | bit(3) | bit(2) | bit(1) | bit(0) + }; + + uint8_t player_id = ds->base.player_id % array_size(player_ids); + + ds->update_player_leds = true; + ds->player_leds_state = player_ids[player_id]; + schedule_work(&ds->output_worker); +} + + ret = ps_device_set_player_id(ps_dev); + if (ret) { + hid_err(hdev, "failed to assign player id for dualsense: %d ", ret); + goto err; + } + + /* set player leds to our player id. */ + dualsense_set_player_leds(ds); + + ps_device_release_player_id(dev); -module_hid_driver(ps_driver); +static int __init ps_init(void) +{ + return hid_register_driver(&ps_driver); +} + +static void __exit ps_exit(void) +{ + hid_unregister_driver(&ps_driver); + ida_destroy(&ps_player_id_allocator); +} + +module_init(ps_init); +module_exit(ps_exit);
Tablets, touch screens, keyboards, mouses
949aaccda019723050a2cd98d7b4492b06423f27
roderick colenbrander
drivers
hid
hid: playstation: add initial dualsense lightbar support.
provide initial support for the dualsense lightbar and configure it with a default playstation blue color.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add initial dualsense lightbar support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'playstation']
['c']
1
65
0
--- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +#define ds_output_valid_flag1_lightbar_control_enable bit(2) +#define ds_output_valid_flag1_release_leds bit(3) +#define ds_output_valid_flag2_lightbar_setup_control_enable bit(1) +#define ds_output_lightbar_setup_light_out bit(1) + /* rgb lightbar */ + bool update_lightbar; + uint8_t lightbar_red; + uint8_t lightbar_green; + uint8_t lightbar_blue; + + if (ds->update_lightbar) { + common->valid_flag1 |= ds_output_valid_flag1_lightbar_control_enable; + common->lightbar_red = ds->lightbar_red; + common->lightbar_green = ds->lightbar_green; + common->lightbar_blue = ds->lightbar_blue; + + ds->update_lightbar = false; + } + +static int dualsense_reset_leds(struct dualsense *ds) +{ + struct dualsense_output_report report; + uint8_t *buf; + + buf = kzalloc(sizeof(struct dualsense_output_report_bt), gfp_kernel); + if (!buf) + return -enomem; + + dualsense_init_output_report(ds, &report, buf); + /* + * on bluetooth the dualsense outputs an animation on the lightbar + * during startup and maintains a color afterwards. we need to explicitly + * reconfigure the lightbar before we can do any programming later on. + * in usb the lightbar is not on by default, but redoing the setup there + * doesn't hurt. + */ + report.common->valid_flag2 = ds_output_valid_flag2_lightbar_setup_control_enable; + report.common->lightbar_setup = ds_output_lightbar_setup_light_out; /* fade light out. */ + dualsense_send_output_report(ds, &report); + + kfree(buf); + return 0; +} + +static void dualsense_set_lightbar(struct dualsense *ds, uint8_t red, uint8_t green, uint8_t blue) +{ + ds->update_lightbar = true; + ds->lightbar_red = red; + ds->lightbar_green = green; + ds->lightbar_blue = blue; + + schedule_work(&ds->output_worker); +} + + /* + * the hardware may have control over the leds (e.g. in bluetooth on startup). + * reset the leds (lightbar, mute, player leds), so we can control them + * from software. + */ + ret = dualsense_reset_leds(ds); + if (ret) + goto err; + + dualsense_set_lightbar(ds, 0, 0, 128); /* blue */ +
Tablets, touch screens, keyboards, mouses
8e5198a12d6416f0a1e9393bdb3a533854ed577b
roderick colenbrander barnab s p cze pobrn protonmail com
drivers
hid
hid: playstation: add microphone mute support for dualsense.
the dualsense controller has a built-in microphone exposed as an audio device over usb (or hid using bluetooth). a dedicated button on the controller handles mute, but software has to configure the device to mute the audio stream.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add microphone mute support for
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'playstation']
['c']
1
44
0
--- diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c +#define ds_buttons2_mic_mute bit(2) +#define ds_output_valid_flag1_mic_mute_led_control_enable bit(0) +#define ds_output_valid_flag1_power_save_control_enable bit(1) +#define ds_output_power_save_control_mic_mute bit(4) + /* microphone */ + bool update_mic_mute; + bool mic_muted; + bool last_btn_mic_state; + + if (ds->update_mic_mute) { + common->valid_flag1 |= ds_output_valid_flag1_mic_mute_led_control_enable; + common->mute_button_led = ds->mic_muted; + + if (ds->mic_muted) { + /* disable microphone */ + common->valid_flag1 |= ds_output_valid_flag1_power_save_control_enable; + common->power_save_control |= ds_output_power_save_control_mic_mute; + } else { + /* enable microphone */ + common->valid_flag1 |= ds_output_valid_flag1_power_save_control_enable; + common->power_save_control &= ~ds_output_power_save_control_mic_mute; + } + + ds->update_mic_mute = false; + } + + bool btn_mic_state; + /* + * the dualsense has an internal microphone, which can be muted through a mute button + * on the device. the driver is expected to read the button state and program the device + * to mute/unmute audio at the hardware level. + */ + btn_mic_state = !!(ds_report->buttons[2] & ds_buttons2_mic_mute); + if (btn_mic_state && !ds->last_btn_mic_state) { + spin_lock_irqsave(&ps_dev->lock, flags); + ds->update_mic_mute = true; + ds->mic_muted = !ds->mic_muted; /* toggle */ + spin_unlock_irqrestore(&ps_dev->lock, flags); + + /* schedule updating of microphone state at hardware level. */ + schedule_work(&ds->output_worker); + } + ds->last_btn_mic_state = btn_mic_state; +
Tablets, touch screens, keyboards, mouses
c26e48b150fccb07c4b7f0f419f2b0a2c42e57d2
roderick colenbrander
drivers
hid
hid: sony: add support for tilt on guitar hero guitars
this commit adds support for tilt on standard guitar hero ps3 guitars, and gh3 pc guitars, mapping it to abs_ry.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add support for tilt on guitar hero guitars
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'sony']
['h', 'kconfig', 'c']
3
20
7
--- diff --git a/drivers/hid/kconfig b/drivers/hid/kconfig --- a/drivers/hid/kconfig +++ b/drivers/hid/kconfig + * guitar hero ps3 and pc guitar dongles diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h +#define usb_vendor_id_activision 0x1430 +#define usb_device_id_activision_guitar_dongle 0x474c + -#define usb_vendor_id_sony_ghlive 0x12ba +#define usb_vendor_id_sony_rhythm 0x12ba +#define usb_device_id_sony_ps3_guitar_dongle 0x0100 diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c + * copyright (c) 2020 sanjay govind <sanjay.govind9@gmail.com> -#define ghl_guitar_ps3wiiu bit(17) +#define gh_guitar_controller bit(17) +#define ghl_guitar_ps3wiiu bit(18) -#define ghl_guitar_tilt_usage 44 +#define guitar_tilt_usage 44 - if (abs == ghl_guitar_tilt_usage) { + if (abs == guitar_tilt_usage) { - if (sc->quirks & ghl_guitar_ps3wiiu) + if (sc->quirks & gh_guitar_controller) - { hid_usb_device(usb_vendor_id_sony_ghlive, usb_device_id_sony_ps3wiiu_ghlive_dongle), - .driver_data = ghl_guitar_ps3wiiu}, + { hid_usb_device(usb_vendor_id_sony_rhythm, usb_device_id_sony_ps3wiiu_ghlive_dongle), + .driver_data = ghl_guitar_ps3wiiu | gh_guitar_controller }, + /* guitar hero pc guitar dongle */ + { hid_usb_device(usb_vendor_id_activision, usb_device_id_activision_guitar_dongle), + .driver_data = gh_guitar_controller }, + /* guitar hero ps3 world tour guitar dongle */ + { hid_usb_device(usb_vendor_id_sony_rhythm, usb_device_id_sony_ps3_guitar_dongle), + .driver_data = gh_guitar_controller },
Tablets, touch screens, keyboards, mouses
32e411d0af7fbf6e8644632271dc1a241b77877e
sanjay govind
drivers
hid
hid: uclogic: improve support for trust panora
after more discussions with the [libinput project][1], it has been determined that the uclogic driver provides better support for this tablet. fortunately, the trust panora is physically and logically identical with the ugee g5, despite having a different usb vendor and product id.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
improve support for trust panora
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['hid ', 'uclogic']
['c']
3
4
1
--- diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c - { hid_usb_device(usb_vendor_id_trust, usb_device_id_trust_panora_tablet), hid_quirk_multi_input | hid_quirk_hidinput_force }, diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c + { hid_usb_device(usb_vendor_id_trust, + usb_device_id_trust_panora_tablet) }, diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c + case vid_pid(usb_vendor_id_trust, + usb_device_id_trust_panora_tablet):
Tablets, touch screens, keyboards, mouses
f7271b2a697d2549db7aa60e0a8e0afeb852faa5
cristian klein
drivers
hid
media: ccs: add digital gain support
ccs supports global (all-component) digital gain. add support for it.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
16
1
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c + break; + + case v4l2_cid_digital_gain: + rval = ccs_write(sensor, digital_gain_global, ctrl->val); + - rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 12); + rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 13); + if (ccs_lim(sensor, digital_gain_capability) == + ccs_digital_gain_capability_global) + v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, + &ccs_ctrl_ops, v4l2_cid_digital_gain, + ccs_lim(sensor, digital_gain_min), + ccs_lim(sensor, digital_gain_max), + max(ccs_lim(sensor, digital_gain_step_size), + 1u), + 0x100); +
TV tuners, webcams, video capturers
7eb5a7e1e7b6cf7153beeba608f5a73d1e912b77
sakari ailus
drivers
media
ccs, i2c
media: ccs: add support for old-style smia digital gain
smia only has per-component digital gain. add support for it.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'c']
2
33
2
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - rval = ccs_write(sensor, digital_gain_global, ctrl->val); + if (ccs_lim(sensor, digital_gain_capability) == + ccs_digital_gain_capability_global) { + rval = ccs_write(sensor, digital_gain_global, + ctrl->val); + break; + } + + rval = ccs_write_addr(sensor, + smiapp_reg_u16_digital_gain_greenr, + ctrl->val); + if (rval) + break; + + rval = ccs_write_addr(sensor, + smiapp_reg_u16_digital_gain_red, + ctrl->val); + if (rval) + break; + + rval = ccs_write_addr(sensor, + smiapp_reg_u16_digital_gain_blue, + ctrl->val); + if (rval) + break; + + rval = ccs_write_addr(sensor, + smiapp_reg_u16_digital_gain_greenb, + ctrl->val); - ccs_digital_gain_capability_global) + ccs_digital_gain_capability_global || + ccs_lim(sensor, digital_gain_capability) == + smiapp_digital_gain_capability_per_channel) diff --git a/drivers/media/i2c/ccs/smiapp-reg-defs.h b/drivers/media/i2c/ccs/smiapp-reg-defs.h --- a/drivers/media/i2c/ccs/smiapp-reg-defs.h +++ b/drivers/media/i2c/ccs/smiapp-reg-defs.h +#define smiapp_digital_gain_capability_per_channel 1 +
TV tuners, webcams, video capturers
821878578975bae1949dbfcef3e39c2968a969c8
sakari ailus
drivers
media
ccs, i2c
media: ccs: remove analogue gain field
the analogue gain control was stored to the device specific struct but was never used. remove it.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'c']
2
6
8
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - sensor->analog_gain = v4l2_ctrl_new_std( - &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, - v4l2_cid_analogue_gain, - ccs_lim(sensor, analog_gain_code_min), - ccs_lim(sensor, analog_gain_code_max), - max(ccs_lim(sensor, analog_gain_code_step), 1u), - ccs_lim(sensor, analog_gain_code_min)); + v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, + v4l2_cid_analogue_gain, + ccs_lim(sensor, analog_gain_code_min), + ccs_lim(sensor, analog_gain_code_max), + max(ccs_lim(sensor, analog_gain_code_step), 1u), + ccs_lim(sensor, analog_gain_code_min)); diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h --- a/drivers/media/i2c/ccs/ccs.h +++ b/drivers/media/i2c/ccs/ccs.h - struct v4l2_ctrl *analog_gain;
TV tuners, webcams, video capturers
d36eb68a49948a7fb29c43bd5745692ede4b6d52
sakari ailus
drivers
media
ccs, i2c
media: ccs: only add analogue gain control if the device supports it
some devices do not implement analogue gain this way. only add the control when a device does have the support.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
10
6
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, - v4l2_cid_analogue_gain, - ccs_lim(sensor, analog_gain_code_min), - ccs_lim(sensor, analog_gain_code_max), - max(ccs_lim(sensor, analog_gain_code_step), 1u), - ccs_lim(sensor, analog_gain_code_min)); + switch (ccs_lim(sensor, analog_gain_capability)) { + case ccs_analog_gain_capability_global: + v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler, + &ccs_ctrl_ops, v4l2_cid_analogue_gain, + ccs_lim(sensor, analog_gain_code_min), + ccs_lim(sensor, analog_gain_code_max), + max(ccs_lim(sensor, analog_gain_code_step), + 1u), + ccs_lim(sensor, analog_gain_code_min)); + }
TV tuners, webcams, video capturers
541374837cd911785ae9307b4902896f2e3b8f15
sakari ailus
drivers
media
ccs, i2c
media: v4l: uapi: add user control base for ccs controls
add a control base for ccs controls, and reserve 128 controls. luckily these numbers are cheap.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h']
1
5
0
--- diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h +/* + * the base for mipi ccs driver controls. + * we reserve 128 controls for this driver. + */ +#define v4l2_cid_user_ccs_base (v4l2_cid_user_base + 0x10f0)
TV tuners, webcams, video capturers
cd9f145dabafec8ad001756f2abe60c7c2ec3cc1
sakari ailus
include
uapi
linux
media: documentation: ccs: add user documentation for the ccs driver
add user documentation for the ccs driver. this includes e.g. sub-devices implemented by the driver.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['maintainers', 'rst']
3
61
0
--- diff --git a/documentation/userspace-api/media/drivers/ccs.rst b/documentation/userspace-api/media/drivers/ccs.rst --- /dev/null +++ b/documentation/userspace-api/media/drivers/ccs.rst +.. spdx-license-identifier: gpl-2.0-only + +.. include:: <isonum.txt> + +mipi ccs camera sensor driver +============================= + +the mipi ccs camera sensor driver is a generic driver for 'mipi ccs +<https://www.mipi.org/specifications/camera-command-set>'_ compliant +camera sensors. it exposes three sub-devices representing the pixel array, +the binner and the scaler. + +as the capabilities of individual devices vary, the driver exposes +interfaces based on the capabilities that exist in hardware. + +pixel array sub-device +---------------------- + +the pixel array sub-device represents the camera sensor's pixel matrix, as well +as analogue crop functionality present in many compliant devices. the analogue +crop is configured using the ''v4l2_sel_tgt_crop'' on the source pad (0) of the +entity. the size of the pixel matrix can be obtained by getting the +''v4l2_sel_tgt_native_size'' target. + +binner +------ + +the binner sub-device represents the binning functionality on the sensor. for +that purpose, selection target ''v4l2_sel_tgt_compose'' is supported on the +sink pad (0). + +additionally, if a device has no scaler or digital crop functionality, the +source pad (1) expses another digital crop selection rectangle that can only +crop at the end of the lines and frames. + +scaler +------ + +the scaler sub-device represents the digital crop and scaling functionality of +the sensor. the v4l2 selection target ''v4l2_sel_tgt_crop'' is used to +configure the digital crop on the sink pad (0) when digital crop is supported. +scaling is configured using selection target ''v4l2_sel_tgt_compose'' on the +sink pad (0) as well. + +additionally, if the scaler sub-device exists, its source pad (1) exposes +another digital crop selection rectangle that can only crop at the end of the +lines and frames. + +digital and analogue crop +------------------------- + +digital crop functionality is referred to as cropping that effectively works by +dropping some data on the floor. analogue crop, on the other hand, means that +the cropped information is never retrieved. in case of camera sensors, the +analogue data is never read from the pixel matrix that are outside the +configured selection rectangle that designates crop. the difference has an +effect in device timing and likely also in power consumption. + +**copyright** |copy| 2020 intel corporation diff --git a/documentation/userspace-api/media/drivers/index.rst b/documentation/userspace-api/media/drivers/index.rst --- a/documentation/userspace-api/media/drivers/index.rst +++ b/documentation/userspace-api/media/drivers/index.rst + ccs diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers +f: documentation/userspace-api/media/drivers/ccs.rst
TV tuners, webcams, video capturers
db08f69ef8205dc4bcc2af2a24bcfc8f9da47899
sakari ailus
documentation
userspace-api
drivers, media
media: v4l: uapi: ccs: add controls for analogue gain constants
add v4l2 controls for analogue gain constants required to control analogue gain. the values are device specific and thus need to be obtained from the driver.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'maintainers', 'rst']
3
40
0
--- diff --git a/documentation/userspace-api/media/drivers/ccs.rst b/documentation/userspace-api/media/drivers/ccs.rst --- a/documentation/userspace-api/media/drivers/ccs.rst +++ b/documentation/userspace-api/media/drivers/ccs.rst +private controls +---------------- + +the mipi ccs driver implements a number of private controls under +''v4l2_cid_user_base_ccs'' to control the mipi ccs compliant camera sensors. + +analogue gain model +~~~~~~~~~~~~~~~~~~~ + +the ccs defines an analogue gain model where the gain can be calculated using +the following formula: + + gain = m0 * x + c0 / (m1 * x + c1) + +either m0 or c0 will be zero. the constants that are device specific, can be +obtained from the following controls: + + v4l2_cid_ccs_analogue_gain_m0 + v4l2_cid_ccs_analogue_gain_m1 + v4l2_cid_ccs_analogue_gain_c0 + v4l2_cid_ccs_analogue_gain_c1 + +the analogue gain (''x'' in the formula) is controlled through +''v4l2_cid_analogue_gain'' in this case. + diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers +f: include/uapi/linux/ccs.h diff --git a/include/uapi/linux/ccs.h b/include/uapi/linux/ccs.h --- /dev/null +++ b/include/uapi/linux/ccs.h +/* spdx-license-identifier: gpl-2.0-only with linux-syscall-note */ +/* copyright (c) 2020 intel corporation */ + +#ifndef __uapi_ccs_h__ +#define __uapi_ccs_h__ + +#include <linux/v4l2-controls.h> + +#define v4l2_cid_ccs_analogue_gain_m0 (v4l2_cid_user_ccs_base + 1) +#define v4l2_cid_ccs_analogue_gain_c0 (v4l2_cid_user_ccs_base + 2) +#define v4l2_cid_ccs_analogue_gain_m1 (v4l2_cid_user_ccs_base + 3) +#define v4l2_cid_ccs_analogue_gain_c1 (v4l2_cid_user_ccs_base + 4) + +#endif
TV tuners, webcams, video capturers
a8a2d75b0897fc359ada5fb9f8b62f985351882b
sakari ailus
documentation
userspace-api
drivers, linux, media
media: ccs: add support for analogue gain coefficient controls
add four controls for reading ccs analogue gain coefficients. the values are constants that are device specific.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
36
2
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c +#include <uapi/linux/ccs.h> - rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 13); + rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 17); - case ccs_analog_gain_capability_global: + case ccs_analog_gain_capability_global: { + struct { + const char *name; + u32 id; + s32 value; + } const gain_ctrls[] = { + { "analogue gain m0", v4l2_cid_ccs_analogue_gain_m0, + ccs_lim(sensor, analog_gain_m0), }, + { "analogue gain c0", v4l2_cid_ccs_analogue_gain_c0, + ccs_lim(sensor, analog_gain_c0), }, + { "analogue gain m1", v4l2_cid_ccs_analogue_gain_m1, + ccs_lim(sensor, analog_gain_m1), }, + { "analogue gain c1", v4l2_cid_ccs_analogue_gain_c1, + ccs_lim(sensor, analog_gain_c1), }, + }; + struct v4l2_ctrl_config ctrl_cfg = { + .type = v4l2_ctrl_type_integer, + .ops = &ccs_ctrl_ops, + .flags = v4l2_ctrl_flag_read_only, + .step = 1, + }; + unsigned int i; + + for (i = 0; i < array_size(gain_ctrls); i++) { + ctrl_cfg.name = gain_ctrls[i].name; + ctrl_cfg.id = gain_ctrls[i].id; + ctrl_cfg.min = ctrl_cfg.max = ctrl_cfg.def = + gain_ctrls[i].value; + + v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, + &ctrl_cfg, null); + } + + }
TV tuners, webcams, video capturers
ee25e211ade18a655953115d642e4c04b17748ed
sakari ailus
drivers
media
ccs, i2c
media: v4l: uapi: ccs: add controls for ccs alternative analogue gain
add two new controls for alternative analogue gain some ccs compliant camera sensors support.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'rst']
2
15
0
--- diff --git a/documentation/userspace-api/media/drivers/ccs.rst b/documentation/userspace-api/media/drivers/ccs.rst --- a/documentation/userspace-api/media/drivers/ccs.rst +++ b/documentation/userspace-api/media/drivers/ccs.rst +alternate analogue gain model +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +the ccs defines another analogue gain model called alternate analogue gain. in +this case, the formula to calculate actual gain consists of linear and +exponential parts: + + gain = linear * 2 ^ exponent + +the ''linear'' and ''exponent'' factors can be set using the +''v4l2_cid_ccs_analogue_linear_gain'' and +''v4l2_cid_ccs_analogue_exponential_gain'' controls, respectively + diff --git a/include/uapi/linux/ccs.h b/include/uapi/linux/ccs.h --- a/include/uapi/linux/ccs.h +++ b/include/uapi/linux/ccs.h +#define v4l2_cid_ccs_analogue_linear_gain (v4l2_cid_user_ccs_base + 5) +#define v4l2_cid_ccs_analogue_exponential_gain (v4l2_cid_user_ccs_base + 6)
TV tuners, webcams, video capturers
a75210a62b81ce8cfbe9e10e29880d870ce94b8d
sakari ailus
include
uapi
drivers, linux, media
media: ccs: add support for alternate analogue global gain
the ccs spec defines an alternative implementation for global analogue gain. add support for that in the driver.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
55
0
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c + case v4l2_cid_ccs_analogue_linear_gain: + rval = ccs_write(sensor, analog_linear_gain_global, ctrl->val); + + break; + + case v4l2_cid_ccs_analogue_exponential_gain: + rval = ccs_write(sensor, analog_exponential_gain_global, + ctrl->val); + + break; + + } + break; + + case ccs_analog_gain_capability_alternate_global: { + struct { + const char *name; + u32 id; + u16 min, max, step; + } const gain_ctrls[] = { + { + "analogue linear gain", + v4l2_cid_ccs_analogue_linear_gain, + ccs_lim(sensor, analog_linear_gain_min), + ccs_lim(sensor, analog_linear_gain_max), + max(ccs_lim(sensor, + analog_linear_gain_step_size), + 1u), + }, + { + "analogue exponential gain", + v4l2_cid_ccs_analogue_exponential_gain, + ccs_lim(sensor, analog_exponential_gain_min), + ccs_lim(sensor, analog_exponential_gain_max), + max(ccs_lim(sensor, + analog_exponential_gain_step_size), + 1u), + }, + }; + struct v4l2_ctrl_config ctrl_cfg = { + .type = v4l2_ctrl_type_integer, + .ops = &ccs_ctrl_ops, + }; + unsigned int i; + + for (i = 0; i < array_size(gain_ctrls); i++) { + ctrl_cfg.name = gain_ctrls[i].name; + ctrl_cfg.min = ctrl_cfg.def = gain_ctrls[i].min; + ctrl_cfg.max = gain_ctrls[i].max; + ctrl_cfg.step = gain_ctrls[i].step; + ctrl_cfg.id = gain_ctrls[i].id; + + v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, + &ctrl_cfg, null); + }
TV tuners, webcams, video capturers
57801b6aa72bee123503fc4630ef4da1b88fca00
sakari ailus
drivers
media
ccs, i2c
media: ccs: add debug prints for msr registers
also print out msr registers written to the sensor. this isn't entirely optimal as the debug strings are produced even if they're not used but that isn't really a grave issue --- the ic bus is very slow anyway.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
8
0
--- diff --git a/drivers/media/i2c/ccs/ccs-reg-access.c b/drivers/media/i2c/ccs/ccs-reg-access.c --- a/drivers/media/i2c/ccs/ccs-reg-access.c +++ b/drivers/media/i2c/ccs/ccs-reg-access.c + char printbuf[(max_write_len << 1) + + 1 /* */] = { 0 }; + bin2hex(printbuf, regdata, msg.len); + dev_dbg(&client->dev, + "writing msr reg 0x%4.4x value 0x%s ", + regs->addr + j, printbuf); + +
TV tuners, webcams, video capturers
7a42609843d2f09de842b825bfefa9fed40e3e7a
sakari ailus
drivers
media
ccs, i2c
media: v4l: uapi: ccs: add ccs controls for shading correction
add v4l2 controls for controlling ccs lens shading correction as well as conveying its capabilities.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'rst']
2
15
0
--- diff --git a/documentation/userspace-api/media/drivers/ccs.rst b/documentation/userspace-api/media/drivers/ccs.rst --- a/documentation/userspace-api/media/drivers/ccs.rst +++ b/documentation/userspace-api/media/drivers/ccs.rst +shading correction +~~~~~~~~~~~~~~~~~~ + +the ccs standard supports lens shading correction. the feature can be controlled +using ''v4l2_cid_ccs_shading_correction''. additionally, the luminance +correction level may be changed using +''v4l2_cid_ccs_luminance_correction_level'', where value 0 indicates no +correction and 128 indicates correcting the luminance in corners to 10 % less +than in the centre. + +shading correction needs to be enabled for luminance correction level to have an +effect. + diff --git a/include/uapi/linux/ccs.h b/include/uapi/linux/ccs.h --- a/include/uapi/linux/ccs.h +++ b/include/uapi/linux/ccs.h +#define v4l2_cid_ccs_shading_correction (v4l2_cid_user_ccs_base + 8) +#define v4l2_cid_ccs_luminance_correction_level (v4l2_cid_user_ccs_base + 9)
TV tuners, webcams, video capturers
7c0ed600f04d247cbb4c4030d87a8d36b12d44a4
sakari ailus
include
uapi
drivers, linux, media
media: ccs: add shading correction and luminance correction level controls
add controls for supporting lens shading correction, including colour shading and luminance correction level.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'c']
2
47
0
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c + break; + case v4l2_cid_ccs_shading_correction: + rval = ccs_write(sensor, shading_correction_en, + ctrl->val ? ccs_shading_correction_en_enable : + 0); + + if (!rval && sensor->luminance_level) + v4l2_ctrl_activate(sensor->luminance_level, ctrl->val); + + break; + case v4l2_cid_ccs_luminance_correction_level: + rval = ccs_write(sensor, luminance_correction_level, ctrl->val); + + if (ccs_lim(sensor, shading_correction_capability) & + (ccs_shading_correction_capability_color_shading | + ccs_shading_correction_capability_luminance_correction)) { + const struct v4l2_ctrl_config ctrl_cfg = { + .name = "shading correction", + .type = v4l2_ctrl_type_boolean, + .id = v4l2_cid_ccs_shading_correction, + .ops = &ccs_ctrl_ops, + .max = 1, + .step = 1, + }; + + v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, + &ctrl_cfg, null); + } + + if (ccs_lim(sensor, shading_correction_capability) & + ccs_shading_correction_capability_luminance_correction) { + const struct v4l2_ctrl_config ctrl_cfg = { + .name = "luminance correction level", + .type = v4l2_ctrl_type_boolean, + .id = v4l2_cid_ccs_luminance_correction_level, + .ops = &ccs_ctrl_ops, + .max = 255, + .step = 1, + .def = 128, + }; + + sensor->luminance_level = + v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler, + &ctrl_cfg, null); + } + diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h --- a/drivers/media/i2c/ccs/ccs.h +++ b/drivers/media/i2c/ccs/ccs.h + struct v4l2_ctrl *luminance_level;
TV tuners, webcams, video capturers
33039a8880710199007621be38dc8f498a0cd5ca
sakari ailus
drivers
media
ccs, i2c
media: ccs: get the endpoint by port rather than any next endpoint
get the first endpoint from port 0 instead of the next one, whatever it might be. there are no other ports so there's no functional change.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
2
1
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - ep = fwnode_graph_get_next_endpoint(fwnode, null); + ep = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, + fwnode_graph_endpoint_next);
TV tuners, webcams, video capturers
d27be0ad943b22d491d1f00e2edbb93a87d58376
sakari ailus
drivers
media
ccs, i2c
media: ccs: don't change the ic address just for software reset
the sensor's address was changed before resetting and changing the address again. don't do it before reset as it's useless.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
0
8
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - if (sensor->hwcfg.i2c_addr_alt) { - rval = ccs_change_cci_addr(sensor); - if (rval) { - dev_err(dev, "cci address change error "); - goto out_cci_addr_fail; - } - } -
TV tuners, webcams, video capturers
105676ce5940517d2a8a4be32f54c9ff8a021ca5
sakari ailus
drivers
media
ccs, i2c
media: ccs: only do software reset if we have no hardware reset
the driver always used software reset after the sensor's power sequence that includes a hardware reset if we have a reset gpio. do not use software reset if we just brought the sensor up from hardware reset state.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
6
4
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - rval = ccs_write(sensor, software_reset, ccs_software_reset_on); - if (rval < 0) { - dev_err(dev, "software reset failed "); - goto out_cci_addr_fail; + if (!sensor->reset && !sensor->xshutdown) { + rval = ccs_write(sensor, software_reset, ccs_software_reset_on); + if (rval < 0) { + dev_err(dev, "software reset failed "); + goto out_cci_addr_fail; + }
TV tuners, webcams, video capturers
e1988e7ad0015e9d8252b515d5aa23a58428022c
sakari ailus
drivers
media
ccs, i2c
media: ccs: wait until software reset is done
verify the software reset has been completed until proceeding.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
15
0
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c + u8 retry = 100; + u32 reset; + + + do { + rval = ccs_read(sensor, software_reset, &reset); + reset = !rval && reset == ccs_software_reset_off; + if (reset) + break; + + usleep_range(1000, 2000); + } while (--retry); + + if (!reset) + return -eio;
TV tuners, webcams, video capturers
51fc72e541b44d5ba52673b1e2b492ffc164b71c
sakari ailus
drivers
media
ccs, i2c
media: ccs: hardware requires a delay after starting the clock of lifting reset
a ccs compliant device requires a delay before the first ic transaction after pulling xshutdown up or starting the external clock. this is what the driver does. however, if neither is actually there, there's no need for the delay.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
16
13
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - unsigned int sleep; - rval = clk_prepare_enable(sensor->ext_clk); - if (rval < 0) { - dev_dbg(dev, "failed to enable xclk "); - goto out_xclk_fail; - } + if (sensor->reset || sensor->xshutdown || sensor->ext_clk) { + unsigned int sleep; + + rval = clk_prepare_enable(sensor->ext_clk); + if (rval < 0) { + dev_dbg(dev, "failed to enable xclk "); + goto out_xclk_fail; + } - gpiod_set_value(sensor->reset, 0); - gpiod_set_value(sensor->xshutdown, 1); + gpiod_set_value(sensor->reset, 0); + gpiod_set_value(sensor->xshutdown, 1); - if (ccsdev->flags & ccs_device_flag_is_smia) - sleep = smiapp_reset_delay(sensor->hwcfg.ext_clk); - else - sleep = 5000; + if (ccsdev->flags & ccs_device_flag_is_smia) + sleep = smiapp_reset_delay(sensor->hwcfg.ext_clk); + else + sleep = 5000; - usleep_range(sleep, sleep); + usleep_range(sleep, sleep); + }
TV tuners, webcams, video capturers
2fed6c84dc6fb9e374466d8a0ba86eb6ca7868f8
sakari ailus
drivers
media
ccs, i2c
media: ccs: add a sanity check for external clock frequency
the driver depends on the external clock frequency. add a sanity check for the frequency, by returning an error from probe if it's zero.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
5
0
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c + if (!sensor->hwcfg.ext_clk) { + dev_err(&client->dev, "cannot work with xclk frequency 0 "); + return -einval; + } +
TV tuners, webcams, video capturers
2f23ecbf40c8c6572017a036505695e1c2ebb7c4
sakari ailus
drivers
media
ccs, i2c
media: ccs: support and default to auto phy control
ccs supports three variants of phy timing control, auto, ui based and manual. the driver previously assumed ui based control that requires updating the link rate to the sensor. now default to automatic control instead, and only write the link rate to the sensor in ui mode.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
43
11
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - /* lane op clock ratio does not apply here. */ - rval = ccs_write(sensor, requested_link_rate, - div_round_up(pll->op_bk.sys_clk_freq_hz, - 1000000 / 256 / 256) * - (pll->flags & ccs_pll_flag_lane_speed_model ? - sensor->pll.csi2.lanes : 1) << - (pll->flags & ccs_pll_flag_op_sys_ddr ? 1 : 0)); - if (rval < 0 || sensor->pll.flags & ccs_pll_flag_no_op_clocks) - return rval; + if (!(ccs_lim(sensor, phy_ctrl_capability) & + ccs_phy_ctrl_capability_auto_phy_ctl)) { + /* lane op clock ratio does not apply here. */ + rval = ccs_write(sensor, requested_link_rate, + div_round_up(pll->op_bk.sys_clk_freq_hz, + 1000000 / 256 / 256) * + (pll->flags & ccs_pll_flag_lane_speed_model ? + sensor->pll.csi2.lanes : 1) << + (pll->flags & ccs_pll_flag_op_sys_ddr ? + 1 : 0)); + if (rval < 0) + return rval; + } + + if (sensor->pll.flags & ccs_pll_flag_no_op_clocks) + return 0; +static int ccs_update_phy_ctrl(struct ccs_sensor *sensor) +{ + struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); + u8 val; + + if (!sensor->ccs_limits) + return 0; + + if (ccs_lim(sensor, phy_ctrl_capability) & + ccs_phy_ctrl_capability_auto_phy_ctl) { + val = ccs_phy_ctrl_auto; + } else if (ccs_lim(sensor, phy_ctrl_capability) & + ccs_phy_ctrl_capability_ui_phy_ctl) { + val = ccs_phy_ctrl_ui; + } else { + dev_err(&client->dev, "manual phy control not supported "); + return -einval; + } + + return ccs_write(sensor, phy_ctrl, val); +} + - /* dphy control done by sensor based on requested link rate */ - rval = ccs_write(sensor, phy_ctrl, ccs_phy_ctrl_ui); + rval = ccs_update_phy_ctrl(sensor); + rval = ccs_update_phy_ctrl(sensor); + if (rval < 0) + goto out_free_ccs_limits; +
TV tuners, webcams, video capturers
9c3d7e5549ebc507c8ec1c516fc163a94d27976d
sakari ailus
drivers
media
ccs, i2c
media: documentation: include ccs pll calculator to ccs driver documentation
include existing ccs pll calculator kerneldoc documentation to the documentation build.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['rst']
1
13
0
--- diff --git a/documentation/driver-api/media/drivers/ccs/ccs.rst b/documentation/driver-api/media/drivers/ccs/ccs.rst --- a/documentation/driver-api/media/drivers/ccs/ccs.rst +++ b/documentation/driver-api/media/drivers/ccs/ccs.rst -l drivers/media/i2c/ccs/ccs-limits.c \ -c documentation/driver-api/media/drivers/ccs/ccs-regs.asc +ccs pll calculator +================== + +the ccs pll calculator is used to compute the pll configuration, given sensor's +capabilities as well as board configuration and user specified configuration. as +the configuration space that encompasses all these configurations is vast, the +pll calculator isn't entirely trivial. yet it is relatively simple to use for a +driver. + +the pll model implemented by the pll calculator corresponds to mipi ccs 1.1. + +.. kernel-doc:: drivers/media/i2c/ccs-pll.h +
TV tuners, webcams, video capturers
81499d338995fa288464c585f49211cfaa6ffdce
sakari ailus
documentation
driver-api
ccs, drivers, media
media: ccs-pll: switch from standard integer types to kernel ones
the preferred integer types in the kernel are the linux specific ones, switch from standard c types to u32 and alike.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'c']
2
100
100
- uint32_t + u32 - uint16_t + u16 - uint8_t + u8 --- diff --git a/drivers/media/i2c/ccs-pll.c b/drivers/media/i2c/ccs-pll.c --- a/drivers/media/i2c/ccs-pll.c +++ b/drivers/media/i2c/ccs-pll.c -static inline uint32_t clk_div_even(uint32_t a) +static inline u32 clk_div_even(u32 a) - return max_t(uint32_t, 1, a & ~1); + return max_t(u32, 1, a & ~1); -static inline uint32_t clk_div_even_up(uint32_t a) +static inline u32 clk_div_even_up(u32 a) -static inline uint32_t is_one_or_even(uint32_t a) +static inline u32 is_one_or_even(u32 a) -static inline uint32_t one_or_more(uint32_t a) +static inline u32 one_or_more(u32 a) -static int bounds_check(struct device *dev, uint32_t val, - uint32_t min, uint32_t max, const char *prefix, +static int bounds_check(struct device *dev, u32 val, + u32 min, u32 max, const char *prefix, -static uint32_t op_sys_ddr(uint32_t flags) +static u32 op_sys_ddr(u32 flags) -static uint32_t op_pix_ddr(uint32_t flags) +static u32 op_pix_ddr(u32 flags) - uint16_t min_vt_div, uint16_t max_vt_div, - uint16_t *min_sys_div, uint16_t *max_sys_div) + u16 min_vt_div, u16 max_vt_div, + u16 *min_sys_div, u16 *max_sys_div) - *min_sys_div = max_t(uint16_t, *min_sys_div, + *min_sys_div = max_t(u16, *min_sys_div, - *min_sys_div = max_t(uint16_t, *min_sys_div, + *min_sys_div = max_t(u16, *min_sys_div, - *max_sys_div = min_t(uint16_t, *max_sys_div, + *max_sys_div = min_t(u16, *max_sys_div, - *max_sys_div = min_t(uint16_t, *max_sys_div, + *max_sys_div = min_t(u16, *max_sys_div, - struct ccs_pll *pll, uint32_t mul, uint32_t div) + struct ccs_pll *pll, u32 mul, u32 div) - uint32_t more_mul; - uint16_t best_pix_div = shrt_max >> 1, best_div; - uint16_t vt_div, min_sys_div, max_sys_div, sys_div; + u32 more_mul; + u16 best_pix_div = shrt_max >> 1, best_div; + u16 vt_div, min_sys_div, max_sys_div, sys_div; - uint16_t pix_div; + u16 pix_div; - uint16_t min_pre_pll_clk_div = lim_fr->min_pre_pll_clk_div; - uint16_t max_pre_pll_clk_div = lim_fr->max_pre_pll_clk_div; - uint32_t pre_mul, pre_div; + u16 min_pre_pll_clk_div = lim_fr->min_pre_pll_clk_div; + u16 max_pre_pll_clk_div = lim_fr->max_pre_pll_clk_div; + u32 pre_mul, pre_div; - min_t(uint16_t, max_pre_pll_clk_div, + min_t(u16, max_pre_pll_clk_div, - min_pre_pll_clk_div = max_t(uint16_t, min_pre_pll_clk_div, + min_pre_pll_clk_div = max_t(u16, min_pre_pll_clk_div, - uint32_t mul, div; + u32 mul, div; - uint32_t phy_const) + u32 phy_const) - uint16_t sys_div; - uint16_t best_pix_div = shrt_max >> 1; - uint16_t vt_op_binning_div; - uint16_t min_vt_div, max_vt_div, vt_div; - uint16_t min_sys_div, max_sys_div; + u16 sys_div; + u16 best_pix_div = shrt_max >> 1; + u16 vt_op_binning_div; + u16 min_vt_div, max_vt_div, vt_div; + u16 min_sys_div, max_sys_div; - min_vt_div = max_t(uint16_t, min_vt_div, + min_vt_div = max_t(u16, min_vt_div, - min_vt_div = max_t(uint16_t, min_vt_div, lim->vt_bk.min_pix_clk_div - * lim->vt_bk.min_sys_clk_div); + min_vt_div = max_t(u16, min_vt_div, lim->vt_bk.min_pix_clk_div + * lim->vt_bk.min_sys_clk_div); - max_vt_div = min_t(uint16_t, max_vt_div, + max_vt_div = min_t(u16, max_vt_div, - uint16_t __max_sys_div = vt_div & 1 ? 1 : max_sys_div; + u16 __max_sys_div = vt_div & 1 ? 1 : max_sys_div; - uint16_t pix_div; - uint16_t rounded_div; + u16 pix_div; + u16 rounded_div; - struct ccs_pll_branch_bk *op_pll_bk, uint32_t mul, - uint32_t div, uint32_t op_sys_clk_freq_hz_sdr, uint32_t l, - bool cphy, uint32_t phy_const) + struct ccs_pll_branch_bk *op_pll_bk, u32 mul, + u32 div, u32 op_sys_clk_freq_hz_sdr, u32 l, + bool cphy, u32 phy_const) - uint32_t more_mul_min, more_mul_max; - uint32_t more_mul_factor; - uint32_t i; + u32 more_mul_min, more_mul_max; + u32 more_mul_factor; + u32 i; - min_t(uint32_t, + min_t(u32, - uint32_t phy_const = cphy ? cphy_const : dphy_const; - uint32_t op_sys_clk_freq_hz_sdr; - uint16_t min_op_pre_pll_clk_div; - uint16_t max_op_pre_pll_clk_div; - uint32_t mul, div; - uint32_t l = (!pll->op_bits_per_lane || - pll->op_bits_per_lane >= pll->bits_per_pixel) ? 1 : 2; - uint32_t i; + u32 phy_const = cphy ? cphy_const : dphy_const; + u32 op_sys_clk_freq_hz_sdr; + u16 min_op_pre_pll_clk_div; + u16 max_op_pre_pll_clk_div; + u32 mul, div; + u32 l = (!pll->op_bits_per_lane || + pll->op_bits_per_lane >= pll->bits_per_pixel) ? 1 : 2; + u32 i; - min_t(uint16_t, op_lim_fr->max_pre_pll_clk_div, + min_t(u16, op_lim_fr->max_pre_pll_clk_div, - max_t(uint16_t, op_lim_fr->min_pre_pll_clk_div, + max_t(u16, op_lim_fr->min_pre_pll_clk_div, - max_t(uint16_t, min_op_pre_pll_clk_div, + max_t(u16, min_op_pre_pll_clk_div, diff --git a/drivers/media/i2c/ccs-pll.h b/drivers/media/i2c/ccs-pll.h --- a/drivers/media/i2c/ccs-pll.h +++ b/drivers/media/i2c/ccs-pll.h - uint16_t pre_pll_clk_div; - uint16_t pll_multiplier; - uint32_t pll_ip_clk_freq_hz; - uint32_t pll_op_clk_freq_hz; + u16 pre_pll_clk_div; + u16 pll_multiplier; + u32 pll_ip_clk_freq_hz; + u32 pll_op_clk_freq_hz; - uint16_t sys_clk_div; - uint16_t pix_clk_div; - uint32_t sys_clk_freq_hz; - uint32_t pix_clk_freq_hz; + u16 sys_clk_div; + u16 pix_clk_div; + u32 sys_clk_freq_hz; + u32 pix_clk_freq_hz; - uint8_t bus_type; - uint8_t op_lanes; - uint8_t vt_lanes; + u8 bus_type; + u8 op_lanes; + u8 vt_lanes; - uint8_t lanes; + u8 lanes; - uint8_t binning_horizontal; - uint8_t binning_vertical; - uint8_t scale_m; - uint8_t scale_n; - uint8_t bits_per_pixel; - uint8_t op_bits_per_lane; - uint16_t flags; - uint32_t link_freq; - uint32_t ext_clk_freq_hz; + u8 binning_horizontal; + u8 binning_vertical; + u8 scale_m; + u8 scale_n; + u8 bits_per_pixel; + u8 op_bits_per_lane; + u16 flags; + u32 link_freq; + u32 ext_clk_freq_hz; - uint32_t pixel_rate_csi; - uint32_t pixel_rate_pixel_array; + u32 pixel_rate_csi; + u32 pixel_rate_pixel_array; - uint16_t min_pre_pll_clk_div; - uint16_t max_pre_pll_clk_div; - uint32_t min_pll_ip_clk_freq_hz; - uint32_t max_pll_ip_clk_freq_hz; - uint16_t min_pll_multiplier; - uint16_t max_pll_multiplier; - uint32_t min_pll_op_clk_freq_hz; - uint32_t max_pll_op_clk_freq_hz; + u16 min_pre_pll_clk_div; + u16 max_pre_pll_clk_div; + u32 min_pll_ip_clk_freq_hz; + u32 max_pll_ip_clk_freq_hz; + u16 min_pll_multiplier; + u16 max_pll_multiplier; + u32 min_pll_op_clk_freq_hz; + u32 max_pll_op_clk_freq_hz; - uint16_t min_sys_clk_div; - uint16_t max_sys_clk_div; - uint32_t min_sys_clk_freq_hz; - uint32_t max_sys_clk_freq_hz; - uint16_t min_pix_clk_div; - uint16_t max_pix_clk_div; - uint32_t min_pix_clk_freq_hz; - uint32_t max_pix_clk_freq_hz; + u16 min_sys_clk_div; + u16 max_sys_clk_div; + u32 min_sys_clk_freq_hz; + u32 max_sys_clk_freq_hz; + u16 min_pix_clk_div; + u16 max_pix_clk_div; + u32 min_pix_clk_freq_hz; + u32 max_pix_clk_freq_hz; - uint32_t min_ext_clk_freq_hz; - uint32_t max_ext_clk_freq_hz; + u32 min_ext_clk_freq_hz; + u32 max_ext_clk_freq_hz; - uint32_t min_line_length_pck_bin; - uint32_t min_line_length_pck; + u32 min_line_length_pck_bin; + u32 min_line_length_pck;
TV tuners, webcams, video capturers
8a75e8dcd2ef409e2bc7bf3141549cd636b4696b
sakari ailus
drivers
media
i2c
media: ccs: switch from standard integer types to kernel ones
the preferred integer types in the kernel are the linux specific ones, switch from standard c types to u32 and alike.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['h', 'c']
3
14
15
--- diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c - uint16_t min_fll, max_fll, min_llp, max_llp, min_lbp; + u16 min_fll, max_fll, min_llp, max_llp, min_lbp; diff --git a/drivers/media/i2c/ccs/ccs-reg-access.c b/drivers/media/i2c/ccs/ccs-reg-access.c --- a/drivers/media/i2c/ccs/ccs-reg-access.c +++ b/drivers/media/i2c/ccs/ccs-reg-access.c -static uint32_t float_to_u32_mul_1000000(struct i2c_client *client, - uint32_t phloat) +static u32 float_to_u32_mul_1000000(struct i2c_client *client, u32 phloat) - int32_t exp; - uint64_t man; + s32 exp; + u64 man; - return sizeof(uint16_t); + return sizeof(u16); - return sizeof(uint32_t); + return sizeof(u32); - return sizeof(uint8_t); + return sizeof(u8); - uint8_t *data; + u8 *data; - case sizeof(uint8_t): + case sizeof(u8): - case sizeof(uint16_t): + case sizeof(u16): - case sizeof(uint32_t): + case sizeof(u32): diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h --- a/drivers/media/i2c/ccs/ccs.h +++ b/drivers/media/i2c/ccs/ccs.h - uint32_t ext_clk; /* sensor external clk */ + u32 ext_clk; /* sensor external clk */ - uint32_t csi_signalling_mode; /* ccs_csi_signalling_mode_* */ - uint64_t *op_sys_clock; + u32 csi_signalling_mode; /* ccs_csi_signalling_mode_* */ + u64 *op_sys_clock;
TV tuners, webcams, video capturers
dffbdf3775d55fa637c456f4ed3025e426e467ec
sakari ailus
drivers
media
ccs, i2c
media: revert "media: ccs-pll: fix module_license"
this reverts commit b3c0115e34adcabe12fce8845e24ca6f04c1554e.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
turn the existing smia driver into a mipi ccs driver while maintaining smia support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
[]
['c']
1
1
1
--- diff --git a/drivers/media/i2c/ccs-pll.c b/drivers/media/i2c/ccs-pll.c --- a/drivers/media/i2c/ccs-pll.c +++ b/drivers/media/i2c/ccs-pll.c -module_license("gpl v2"); +module_license("gpl");
TV tuners, webcams, video capturers
ca59318b9a5f677fbf2e774aad2f25cd580a03c8
sakari ailus
drivers
media
i2c
media: allegro: extract rbsp handler from h.264 nal generator
the rbsp structure is the same for hevc and h.264. in order to be able to reuse the rbsp handler for generating hevc nal units, extract the functions from the h.264 generator.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['h', 'c', 'makefile']
4
374
330
--- diff --git a/drivers/media/platform/allegro-dvt/makefile b/drivers/media/platform/allegro-dvt/makefile --- a/drivers/media/platform/allegro-dvt/makefile +++ b/drivers/media/platform/allegro-dvt/makefile -allegro-objs := allegro-core.o nal-h264.o allegro-mail.o +allegro-objs := allegro-core.o allegro-mail.o +allegro-objs += nal-rbsp.o nal-h264.o diff --git a/drivers/media/platform/allegro-dvt/nal-h264.c b/drivers/media/platform/allegro-dvt/nal-h264.c --- a/drivers/media/platform/allegro-dvt/nal-h264.c +++ b/drivers/media/platform/allegro-dvt/nal-h264.c +#include "nal-rbsp.h" -struct rbsp; - -struct nal_h264_ops { - int (*rbsp_bit)(struct rbsp *rbsp, int *val); - int (*rbsp_bits)(struct rbsp *rbsp, int n, unsigned int *val); - int (*rbsp_uev)(struct rbsp *rbsp, unsigned int *val); - int (*rbsp_sev)(struct rbsp *rbsp, int *val); -}; - -/** - * struct rbsp - state object for handling a raw byte sequence payload - * @data: pointer to the data of the rbsp - * @size: maximum size of the data of the rbsp - * @pos: current bit position inside the rbsp - * @num_consecutive_zeros: number of zeros before @pos - * @ops: per datatype functions for interacting with the rbsp - * @error: an error occurred while handling the rbsp - * - * this struct is passed around the various parsing functions and tracks the - * current position within the raw byte sequence payload. - * - * the @ops field allows to separate the operation, i.e., reading/writing a - * value from/to that rbsp, from the structure of the nal unit. this allows to - * have a single function for iterating the nal unit, while @ops has function - * pointers for handling each type in the rbsp. - */ -struct rbsp { - u8 *data; - size_t size; - unsigned int pos; - unsigned int num_consecutive_zeros; - struct nal_h264_ops *ops; - int error; -}; - -static void rbsp_init(struct rbsp *rbsp, void *addr, size_t size, - struct nal_h264_ops *ops) -{ - if (!rbsp) - return; - - rbsp->data = addr; - rbsp->size = size; - rbsp->pos = 0; - rbsp->ops = ops; - rbsp->error = 0; -} - -static int rbsp_read_bits(struct rbsp *rbsp, int n, unsigned int *value); -static int rbsp_write_bits(struct rbsp *rbsp, int n, unsigned int value); - -/* - * when reading or writing, the emulation_prevention_three_byte is detected - * only when the 2 one bits need to be inserted. therefore, we are not - * actually adding the 0x3 byte, but the 2 one bits and the six 0 bits of the - * next byte. - */ -#define emulation_prevention_three_byte (0x3 << 6) - -static int add_emulation_prevention_three_byte(struct rbsp *rbsp) -{ - rbsp->num_consecutive_zeros = 0; - rbsp_write_bits(rbsp, 8, emulation_prevention_three_byte); - - return 0; -} - -static int discard_emulation_prevention_three_byte(struct rbsp *rbsp) -{ - unsigned int tmp = 0; - - rbsp->num_consecutive_zeros = 0; - rbsp_read_bits(rbsp, 8, &tmp); - if (tmp != emulation_prevention_three_byte) - return -einval; - - return 0; -} - -static inline int rbsp_read_bit(struct rbsp *rbsp) -{ - int shift; - int ofs; - int bit; - int err; - - if (rbsp->num_consecutive_zeros == 22) { - err = discard_emulation_prevention_three_byte(rbsp); - if (err) - return err; - } - - shift = 7 - (rbsp->pos % 8); - ofs = rbsp->pos / 8; - if (ofs >= rbsp->size) - return -einval; - - bit = (rbsp->data[ofs] >> shift) & 1; - - rbsp->pos++; - - if (bit == 1 || - (rbsp->num_consecutive_zeros < 7 && (rbsp->pos % 8 == 0))) - rbsp->num_consecutive_zeros = 0; - else - rbsp->num_consecutive_zeros++; - - return bit; -} - -static inline int rbsp_write_bit(struct rbsp *rbsp, bool value) -{ - int shift; - int ofs; - - if (rbsp->num_consecutive_zeros == 22) - add_emulation_prevention_three_byte(rbsp); - - shift = 7 - (rbsp->pos % 8); - ofs = rbsp->pos / 8; - if (ofs >= rbsp->size) - return -einval; - - rbsp->data[ofs] &= ~(1 << shift); - rbsp->data[ofs] |= value << shift; - - rbsp->pos++; - - if (value || - (rbsp->num_consecutive_zeros < 7 && (rbsp->pos % 8 == 0))) { - rbsp->num_consecutive_zeros = 0; - } else { - rbsp->num_consecutive_zeros++; - } - - return 0; -} - -static inline int rbsp_read_bits(struct rbsp *rbsp, int n, unsigned int *value) -{ - int i; - int bit; - unsigned int tmp = 0; - - if (n > 8 * sizeof(*value)) - return -einval; - - for (i = n; i > 0; i--) { - bit = rbsp_read_bit(rbsp); - if (bit < 0) - return bit; - tmp |= bit << (i - 1); - } - - if (value) - *value = tmp; - - return 0; -} - -static int rbsp_write_bits(struct rbsp *rbsp, int n, unsigned int value) -{ - int ret; - - if (n > 8 * sizeof(value)) - return -einval; - - while (n--) { - ret = rbsp_write_bit(rbsp, (value >> n) & 1); - if (ret) - return ret; - } - - return 0; -} - -static int rbsp_read_uev(struct rbsp *rbsp, unsigned int *value) -{ - int leading_zero_bits = 0; - unsigned int tmp = 0; - int ret; - - while ((ret = rbsp_read_bit(rbsp)) == 0) - leading_zero_bits++; - if (ret < 0) - return ret; - - if (leading_zero_bits > 0) { - ret = rbsp_read_bits(rbsp, leading_zero_bits, &tmp); - if (ret) - return ret; - } - - if (value) - *value = (1 << leading_zero_bits) - 1 + tmp; - - return 0; -} - -static int rbsp_write_uev(struct rbsp *rbsp, unsigned int *value) -{ - int ret; - int leading_zero_bits; - - if (!value) - return -einval; - - leading_zero_bits = ilog2(*value + 1); - - ret = rbsp_write_bits(rbsp, leading_zero_bits, 0); - if (ret) - return ret; - - return rbsp_write_bits(rbsp, leading_zero_bits + 1, *value + 1); -} - -static int rbsp_read_sev(struct rbsp *rbsp, int *value) -{ - int ret; - unsigned int tmp; - - ret = rbsp_read_uev(rbsp, &tmp); - if (ret) - return ret; - - if (value) { - if (tmp & 1) - *value = (tmp + 1) / 2; - else - *value = -(tmp / 2); - } - - return 0; -} - -static int rbsp_write_sev(struct rbsp *rbsp, int *value) -{ - unsigned int tmp; - - if (!value) - return -einval; - - if (*value > 0) - tmp = (2 * (*value)) | 1; - else - tmp = -2 * (*value); - - return rbsp_write_uev(rbsp, &tmp); -} - -static int __rbsp_write_bit(struct rbsp *rbsp, int *value) -{ - return rbsp_write_bit(rbsp, *value); -} - -static int __rbsp_write_bits(struct rbsp *rbsp, int n, unsigned int *value) -{ - return rbsp_write_bits(rbsp, n, *value); -} - -static struct nal_h264_ops write = { - .rbsp_bit = __rbsp_write_bit, - .rbsp_bits = __rbsp_write_bits, - .rbsp_uev = rbsp_write_uev, - .rbsp_sev = rbsp_write_sev, -}; - -static int __rbsp_read_bit(struct rbsp *rbsp, int *value) -{ - int tmp = rbsp_read_bit(rbsp); - - if (tmp < 0) - return tmp; - *value = tmp; - - return 0; -} - -static struct nal_h264_ops read = { - .rbsp_bit = __rbsp_read_bit, - .rbsp_bits = rbsp_read_bits, - .rbsp_uev = rbsp_read_uev, - .rbsp_sev = rbsp_read_sev, -}; - -static inline void rbsp_bit(struct rbsp *rbsp, int *value) -{ - if (rbsp->error) - return; - rbsp->error = rbsp->ops->rbsp_bit(rbsp, value); -} - -static inline void rbsp_bits(struct rbsp *rbsp, int n, int *value) -{ - if (rbsp->error) - return; - rbsp->error = rbsp->ops->rbsp_bits(rbsp, n, value); -} - -static inline void rbsp_uev(struct rbsp *rbsp, unsigned int *value) -{ - if (rbsp->error) - return; - rbsp->error = rbsp->ops->rbsp_uev(rbsp, value); -} - -static inline void rbsp_sev(struct rbsp *rbsp, int *value) -{ - if (rbsp->error) - return; - rbsp->error = rbsp->ops->rbsp_sev(rbsp, value); -} - -static void nal_h264_rbsp_trailing_bits(struct rbsp *rbsp) -{ - unsigned int rbsp_stop_one_bit = 1; - unsigned int rbsp_alignment_zero_bit = 0; - - rbsp_bit(rbsp, &rbsp_stop_one_bit); - rbsp_bits(rbsp, round_up(rbsp->pos, 8) - rbsp->pos, - &rbsp_alignment_zero_bit); -} - - nal_h264_rbsp_trailing_bits(&rbsp); + rbsp_trailing_bits(&rbsp); - nal_h264_rbsp_trailing_bits(&rbsp); + rbsp_trailing_bits(&rbsp); - nal_h264_rbsp_trailing_bits(&rbsp); + rbsp_trailing_bits(&rbsp); - nal_h264_rbsp_trailing_bits(&rbsp); + rbsp_trailing_bits(&rbsp); - nal_h264_rbsp_trailing_bits(&rbsp); + rbsp_trailing_bits(&rbsp); - nal_h264_rbsp_trailing_bits(&rbsp); + rbsp_trailing_bits(&rbsp); diff --git a/drivers/media/platform/allegro-dvt/nal-rbsp.c b/drivers/media/platform/allegro-dvt/nal-rbsp.c --- /dev/null +++ b/drivers/media/platform/allegro-dvt/nal-rbsp.c +// spdx-license-identifier: gpl-2.0 +/* + * copyright (c) 2019-2020 pengutronix, michael tretter <kernel@pengutronix.de> + * + * helper functions to generate a raw byte sequence payload from values. + */ + +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/string.h> +#include <linux/v4l2-controls.h> + +#include <linux/device.h> +#include <linux/export.h> +#include <linux/log2.h> + +#include "nal-rbsp.h" + +void rbsp_init(struct rbsp *rbsp, void *addr, size_t size, + struct nal_rbsp_ops *ops) +{ + if (!rbsp) + return; + + rbsp->data = addr; + rbsp->size = size; + rbsp->pos = 0; + rbsp->ops = ops; + rbsp->error = 0; +} + +static int rbsp_read_bits(struct rbsp *rbsp, int n, unsigned int *value); +static int rbsp_write_bits(struct rbsp *rbsp, int n, unsigned int value); + +/* + * when reading or writing, the emulation_prevention_three_byte is detected + * only when the 2 one bits need to be inserted. therefore, we are not + * actually adding the 0x3 byte, but the 2 one bits and the six 0 bits of the + * next byte. + */ +#define emulation_prevention_three_byte (0x3 << 6) + +static int add_emulation_prevention_three_byte(struct rbsp *rbsp) +{ + rbsp->num_consecutive_zeros = 0; + rbsp_write_bits(rbsp, 8, emulation_prevention_three_byte); + + return 0; +} + +static int discard_emulation_prevention_three_byte(struct rbsp *rbsp) +{ + unsigned int tmp = 0; + + rbsp->num_consecutive_zeros = 0; + rbsp_read_bits(rbsp, 8, &tmp); + if (tmp != emulation_prevention_three_byte) + return -einval; + + return 0; +} + +static inline int rbsp_read_bit(struct rbsp *rbsp) +{ + int shift; + int ofs; + int bit; + int err; + + if (rbsp->num_consecutive_zeros == 22) { + err = discard_emulation_prevention_three_byte(rbsp); + if (err) + return err; + } + + shift = 7 - (rbsp->pos % 8); + ofs = rbsp->pos / 8; + if (ofs >= rbsp->size) + return -einval; + + bit = (rbsp->data[ofs] >> shift) & 1; + + rbsp->pos++; + + if (bit == 1 || + (rbsp->num_consecutive_zeros < 7 && (rbsp->pos % 8 == 0))) + rbsp->num_consecutive_zeros = 0; + else + rbsp->num_consecutive_zeros++; + + return bit; +} + +static inline int rbsp_write_bit(struct rbsp *rbsp, bool value) +{ + int shift; + int ofs; + + if (rbsp->num_consecutive_zeros == 22) + add_emulation_prevention_three_byte(rbsp); + + shift = 7 - (rbsp->pos % 8); + ofs = rbsp->pos / 8; + if (ofs >= rbsp->size) + return -einval; + + rbsp->data[ofs] &= ~(1 << shift); + rbsp->data[ofs] |= value << shift; + + rbsp->pos++; + + if (value || + (rbsp->num_consecutive_zeros < 7 && (rbsp->pos % 8 == 0))) { + rbsp->num_consecutive_zeros = 0; + } else { + rbsp->num_consecutive_zeros++; + } + + return 0; +} + +static inline int rbsp_read_bits(struct rbsp *rbsp, int n, unsigned int *value) +{ + int i; + int bit; + unsigned int tmp = 0; + + if (n > 8 * sizeof(*value)) + return -einval; + + for (i = n; i > 0; i--) { + bit = rbsp_read_bit(rbsp); + if (bit < 0) + return bit; + tmp |= bit << (i - 1); + } + + if (value) + *value = tmp; + + return 0; +} + +static int rbsp_write_bits(struct rbsp *rbsp, int n, unsigned int value) +{ + int ret; + + if (n > 8 * sizeof(value)) + return -einval; + + while (n--) { + ret = rbsp_write_bit(rbsp, (value >> n) & 1); + if (ret) + return ret; + } + + return 0; +} + +static int rbsp_read_uev(struct rbsp *rbsp, unsigned int *value) +{ + int leading_zero_bits = 0; + unsigned int tmp = 0; + int ret; + + while ((ret = rbsp_read_bit(rbsp)) == 0) + leading_zero_bits++; + if (ret < 0) + return ret; + + if (leading_zero_bits > 0) { + ret = rbsp_read_bits(rbsp, leading_zero_bits, &tmp); + if (ret) + return ret; + } + + if (value) + *value = (1 << leading_zero_bits) - 1 + tmp; + + return 0; +} + +static int rbsp_write_uev(struct rbsp *rbsp, unsigned int *value) +{ + int ret; + int leading_zero_bits; + + if (!value) + return -einval; + + leading_zero_bits = ilog2(*value + 1); + + ret = rbsp_write_bits(rbsp, leading_zero_bits, 0); + if (ret) + return ret; + + return rbsp_write_bits(rbsp, leading_zero_bits + 1, *value + 1); +} + +static int rbsp_read_sev(struct rbsp *rbsp, int *value) +{ + int ret; + unsigned int tmp; + + ret = rbsp_read_uev(rbsp, &tmp); + if (ret) + return ret; + + if (value) { + if (tmp & 1) + *value = (tmp + 1) / 2; + else + *value = -(tmp / 2); + } + + return 0; +} + +static int rbsp_write_sev(struct rbsp *rbsp, int *value) +{ + unsigned int tmp; + + if (!value) + return -einval; + + if (*value > 0) + tmp = (2 * (*value)) | 1; + else + tmp = -2 * (*value); + + return rbsp_write_uev(rbsp, &tmp); +} + +static int __rbsp_write_bit(struct rbsp *rbsp, int *value) +{ + return rbsp_write_bit(rbsp, *value); +} + +static int __rbsp_write_bits(struct rbsp *rbsp, int n, unsigned int *value) +{ + return rbsp_write_bits(rbsp, n, *value); +} + +struct nal_rbsp_ops write = { + .rbsp_bit = __rbsp_write_bit, + .rbsp_bits = __rbsp_write_bits, + .rbsp_uev = rbsp_write_uev, + .rbsp_sev = rbsp_write_sev, +}; + +static int __rbsp_read_bit(struct rbsp *rbsp, int *value) +{ + int tmp = rbsp_read_bit(rbsp); + + if (tmp < 0) + return tmp; + *value = tmp; + + return 0; +} + +struct nal_rbsp_ops read = { + .rbsp_bit = __rbsp_read_bit, + .rbsp_bits = rbsp_read_bits, + .rbsp_uev = rbsp_read_uev, + .rbsp_sev = rbsp_read_sev, +}; + +void rbsp_bit(struct rbsp *rbsp, int *value) +{ + if (rbsp->error) + return; + rbsp->error = rbsp->ops->rbsp_bit(rbsp, value); +} + +void rbsp_bits(struct rbsp *rbsp, int n, int *value) +{ + if (rbsp->error) + return; + rbsp->error = rbsp->ops->rbsp_bits(rbsp, n, value); +} + +void rbsp_uev(struct rbsp *rbsp, unsigned int *value) +{ + if (rbsp->error) + return; + rbsp->error = rbsp->ops->rbsp_uev(rbsp, value); +} + +void rbsp_sev(struct rbsp *rbsp, int *value) +{ + if (rbsp->error) + return; + rbsp->error = rbsp->ops->rbsp_sev(rbsp, value); +} + +void rbsp_trailing_bits(struct rbsp *rbsp) +{ + unsigned int rbsp_stop_one_bit = 1; + unsigned int rbsp_alignment_zero_bit = 0; + + rbsp_bit(rbsp, &rbsp_stop_one_bit); + rbsp_bits(rbsp, round_up(rbsp->pos, 8) - rbsp->pos, + &rbsp_alignment_zero_bit); +} diff --git a/drivers/media/platform/allegro-dvt/nal-rbsp.h b/drivers/media/platform/allegro-dvt/nal-rbsp.h --- /dev/null +++ b/drivers/media/platform/allegro-dvt/nal-rbsp.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * copyright (c) 2019-2020 pengutronix, michael tretter <kernel@pengutronix.de> + */ + +#ifndef __nal_rbsp_h__ +#define __nal_rbsp_h__ + +#include <linux/kernel.h> +#include <linux/types.h> + +struct rbsp; + +struct nal_rbsp_ops { + int (*rbsp_bit)(struct rbsp *rbsp, int *val); + int (*rbsp_bits)(struct rbsp *rbsp, int n, unsigned int *val); + int (*rbsp_uev)(struct rbsp *rbsp, unsigned int *val); + int (*rbsp_sev)(struct rbsp *rbsp, int *val); +}; + +/** + * struct rbsp - state object for handling a raw byte sequence payload + * @data: pointer to the data of the rbsp + * @size: maximum size of the data of the rbsp + * @pos: current bit position inside the rbsp + * @num_consecutive_zeros: number of zeros before @pos + * @ops: per datatype functions for interacting with the rbsp + * @error: an error occurred while handling the rbsp + * + * this struct is passed around the various parsing functions and tracks the + * current position within the raw byte sequence payload. + * + * the @ops field allows to separate the operation, i.e., reading/writing a + * value from/to that rbsp, from the structure of the nal unit. this allows to + * have a single function for iterating the nal unit, while @ops has function + * pointers for handling each type in the rbsp. + */ +struct rbsp { + u8 *data; + size_t size; + unsigned int pos; + unsigned int num_consecutive_zeros; + struct nal_rbsp_ops *ops; + int error; +}; + +extern struct nal_rbsp_ops write; +extern struct nal_rbsp_ops read; + +void rbsp_init(struct rbsp *rbsp, void *addr, size_t size, + struct nal_rbsp_ops *ops); + +void rbsp_bit(struct rbsp *rbsp, int *value); +void rbsp_bits(struct rbsp *rbsp, int n, int *value); +void rbsp_uev(struct rbsp *rbsp, unsigned int *value); +void rbsp_sev(struct rbsp *rbsp, int *value); + +void rbsp_trailing_bits(struct rbsp *rbsp); + +#endif /* __nal_rbsp_h__ */
TV tuners, webcams, video capturers
256442881b1726a671befa47b7f92cd5d11b7ad5
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: add helper to report unsupported fields
allow generators to explicitly signal an error if the c structs contain unsupported or invalid fields.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['h', 'c']
2
6
0
--- diff --git a/drivers/media/platform/allegro-dvt/nal-rbsp.c b/drivers/media/platform/allegro-dvt/nal-rbsp.c --- a/drivers/media/platform/allegro-dvt/nal-rbsp.c +++ b/drivers/media/platform/allegro-dvt/nal-rbsp.c +void rbsp_unsupported(struct rbsp *rbsp) +{ + rbsp->error = -einval; +} + diff --git a/drivers/media/platform/allegro-dvt/nal-rbsp.h b/drivers/media/platform/allegro-dvt/nal-rbsp.h --- a/drivers/media/platform/allegro-dvt/nal-rbsp.h +++ b/drivers/media/platform/allegro-dvt/nal-rbsp.h +void rbsp_unsupported(struct rbsp *rbsp);
TV tuners, webcams, video capturers
98c588b6d27c04460a590f55f1e2474129abe87c
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: add hevc nal unit generator
when encoding a video as hevc, the allegro driver needs to generate the non-vcl nal units for hevc. do the same as for h.264 and add a module that takes c structs for the vps/sps/pps and encodes the fields as rbps as specified by "itu-t rec. h.265 (02/2018) high efficiency video coding".
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['h', 'c', 'makefile']
3
1,175
1
--- diff --git a/drivers/media/platform/allegro-dvt/makefile b/drivers/media/platform/allegro-dvt/makefile --- a/drivers/media/platform/allegro-dvt/makefile +++ b/drivers/media/platform/allegro-dvt/makefile -allegro-objs += nal-rbsp.o nal-h264.o +allegro-objs += nal-rbsp.o nal-h264.o nal-hevc.o diff --git a/drivers/media/platform/allegro-dvt/nal-hevc.c b/drivers/media/platform/allegro-dvt/nal-hevc.c --- /dev/null +++ b/drivers/media/platform/allegro-dvt/nal-hevc.c +// spdx-license-identifier: gpl-2.0 +/* + * copyright (c) 2019-2020 pengutronix, michael tretter <kernel@pengutronix.de> + * + * convert nal units between raw byte sequence payloads (rbsp) and c structs. + * + * the conversion is defined in "itu-t rec. h.265 (02/2018) high efficiency + * video coding". decoder drivers may use the parser to parse rbsp from + * encoded streams and configure the hardware, if the hardware is not able to + * parse rbsp itself. encoder drivers may use the generator to generate the + * rbsp for vps/sps/pps nal units and add them to the encoded stream if the + * hardware does not generate the units. + */ + +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/string.h> +#include <linux/v4l2-controls.h> + +#include <linux/device.h> +#include <linux/export.h> +#include <linux/log2.h> + +#include "nal-hevc.h" +#include "nal-rbsp.h" + +/* + * see rec. itu-t h.265 (02/2018) table 7-1 nal unit type codes and nal unit + * type classes + */ +enum nal_unit_type { + vps_nut = 32, + sps_nut = 33, + pps_nut = 34, + fd_nut = 38, +}; + +int nal_hevc_profile_from_v4l2(enum v4l2_mpeg_video_hevc_profile profile) +{ + switch (profile) { + case v4l2_mpeg_video_hevc_profile_main: + return 1; + case v4l2_mpeg_video_hevc_profile_main_10: + return 2; + case v4l2_mpeg_video_hevc_profile_main_still_picture: + return 3; + default: + return -einval; + } +} +export_symbol_gpl(nal_hevc_profile_from_v4l2); + +int nal_hevc_tier_from_v4l2(enum v4l2_mpeg_video_hevc_tier tier) +{ + switch (tier) { + case v4l2_mpeg_video_hevc_tier_main: + return 0; + case v4l2_mpeg_video_hevc_tier_high: + return 1; + default: + return -einval; + } +} +export_symbol_gpl(nal_hevc_tier_from_v4l2); + +int nal_hevc_level_from_v4l2(enum v4l2_mpeg_video_hevc_level level) +{ + /* + * t-rec-h.265 p. 280: general_level_idc and sub_layer_level_idc[ i ] + * shall be set equal to a value of 30 times the level number + * specified in table a.6. + */ + int factor = 30 / 10; + + switch (level) { + case v4l2_mpeg_video_hevc_level_1: + return factor * 10; + case v4l2_mpeg_video_hevc_level_2: + return factor * 20; + case v4l2_mpeg_video_hevc_level_2_1: + return factor * 21; + case v4l2_mpeg_video_hevc_level_3: + return factor * 30; + case v4l2_mpeg_video_hevc_level_3_1: + return factor * 31; + case v4l2_mpeg_video_hevc_level_4: + return factor * 40; + case v4l2_mpeg_video_hevc_level_4_1: + return factor * 41; + case v4l2_mpeg_video_hevc_level_5: + return factor * 50; + case v4l2_mpeg_video_hevc_level_5_1: + return factor * 51; + case v4l2_mpeg_video_hevc_level_5_2: + return factor * 52; + case v4l2_mpeg_video_hevc_level_6: + return factor * 60; + case v4l2_mpeg_video_hevc_level_6_1: + return factor * 61; + case v4l2_mpeg_video_hevc_level_6_2: + return factor * 62; + default: + return -einval; + } +} +export_symbol_gpl(nal_hevc_level_from_v4l2); + +static void nal_hevc_write_start_code_prefix(struct rbsp *rbsp) +{ + u8 *p = rbsp->data + div_round_up(rbsp->pos, 8); + int i = 4; + + if (div_round_up(rbsp->pos, 8) + i > rbsp->size) { + rbsp->error = -einval; + return; + } + + p[0] = 0x00; + p[1] = 0x00; + p[2] = 0x00; + p[3] = 0x01; + + rbsp->pos += i * 8; +} + +static void nal_hevc_read_start_code_prefix(struct rbsp *rbsp) +{ + u8 *p = rbsp->data + div_round_up(rbsp->pos, 8); + int i = 4; + + if (div_round_up(rbsp->pos, 8) + i > rbsp->size) { + rbsp->error = -einval; + return; + } + + if (p[0] != 0x00 || p[1] != 0x00 || p[2] != 0x00 || p[3] != 0x01) { + rbsp->error = -einval; + return; + } + + rbsp->pos += i * 8; +} + +static void nal_hevc_write_filler_data(struct rbsp *rbsp) +{ + u8 *p = rbsp->data + div_round_up(rbsp->pos, 8); + int i; + + /* keep 1 byte extra for terminating the nal unit */ + i = rbsp->size - div_round_up(rbsp->pos, 8) - 1; + memset(p, 0xff, i); + rbsp->pos += i * 8; +} + +static void nal_hevc_read_filler_data(struct rbsp *rbsp) +{ + u8 *p = rbsp->data + div_round_up(rbsp->pos, 8); + + while (*p == 0xff) { + if (div_round_up(rbsp->pos, 8) > rbsp->size) { + rbsp->error = -einval; + return; + } + + p++; + rbsp->pos += 8; + } +} + +static void nal_hevc_rbsp_profile_tier_level(struct rbsp *rbsp, + struct nal_hevc_profile_tier_level *ptl) +{ + unsigned int i; + unsigned int max_num_sub_layers_minus_1 = 0; + + rbsp_bits(rbsp, 2, &ptl->general_profile_space); + rbsp_bit(rbsp, &ptl->general_tier_flag); + rbsp_bits(rbsp, 5, &ptl->general_profile_idc); + for (i = 0; i < 32; i++) + rbsp_bit(rbsp, &ptl->general_profile_compatibility_flag[i]); + rbsp_bit(rbsp, &ptl->general_progressive_source_flag); + rbsp_bit(rbsp, &ptl->general_interlaced_source_flag); + rbsp_bit(rbsp, &ptl->general_non_packed_constraint_flag); + rbsp_bit(rbsp, &ptl->general_frame_only_constraint_flag); + if (ptl->general_profile_idc == 4 || + ptl->general_profile_compatibility_flag[4] || + ptl->general_profile_idc == 5 || + ptl->general_profile_compatibility_flag[5] || + ptl->general_profile_idc == 6 || + ptl->general_profile_compatibility_flag[6] || + ptl->general_profile_idc == 7 || + ptl->general_profile_compatibility_flag[7] || + ptl->general_profile_idc == 8 || + ptl->general_profile_compatibility_flag[8] || + ptl->general_profile_idc == 9 || + ptl->general_profile_compatibility_flag[9] || + ptl->general_profile_idc == 10 || + ptl->general_profile_compatibility_flag[10]) { + rbsp_bit(rbsp, &ptl->general_max_12bit_constraint_flag); + rbsp_bit(rbsp, &ptl->general_max_10bit_constraint_flag); + rbsp_bit(rbsp, &ptl->general_max_8bit_constraint_flag); + rbsp_bit(rbsp, &ptl->general_max_422chroma_constraint_flag); + rbsp_bit(rbsp, &ptl->general_max_420chroma_constraint_flag); + rbsp_bit(rbsp, &ptl->general_max_monochrome_constraint_flag); + rbsp_bit(rbsp, &ptl->general_intra_constraint_flag); + rbsp_bit(rbsp, &ptl->general_one_picture_only_constraint_flag); + rbsp_bit(rbsp, &ptl->general_lower_bit_rate_constraint_flag); + if (ptl->general_profile_idc == 5 || + ptl->general_profile_compatibility_flag[5] || + ptl->general_profile_idc == 9 || + ptl->general_profile_compatibility_flag[9] || + ptl->general_profile_idc == 10 || + ptl->general_profile_compatibility_flag[10]) { + rbsp_bit(rbsp, &ptl->general_max_14bit_constraint_flag); + rbsp_bits(rbsp, 32, &ptl->general_reserved_zero_33bits); + rbsp_bits(rbsp, 33 - 32, &ptl->general_reserved_zero_33bits); + } else { + rbsp_bits(rbsp, 32, &ptl->general_reserved_zero_34bits); + rbsp_bits(rbsp, 34 - 2, &ptl->general_reserved_zero_34bits); + } + } else if (ptl->general_profile_idc == 2 || + ptl->general_profile_compatibility_flag[2]) { + rbsp_bits(rbsp, 7, &ptl->general_reserved_zero_7bits); + rbsp_bit(rbsp, &ptl->general_one_picture_only_constraint_flag); + rbsp_bits(rbsp, 32, &ptl->general_reserved_zero_35bits); + rbsp_bits(rbsp, 35 - 32, &ptl->general_reserved_zero_35bits); + } else { + rbsp_bits(rbsp, 32, &ptl->general_reserved_zero_43bits); + rbsp_bits(rbsp, 43 - 32, &ptl->general_reserved_zero_43bits); + } + if ((ptl->general_profile_idc >= 1 && ptl->general_profile_idc <= 5) || + ptl->general_profile_idc == 9 || + ptl->general_profile_compatibility_flag[1] || + ptl->general_profile_compatibility_flag[2] || + ptl->general_profile_compatibility_flag[3] || + ptl->general_profile_compatibility_flag[4] || + ptl->general_profile_compatibility_flag[5] || + ptl->general_profile_compatibility_flag[9]) + rbsp_bit(rbsp, &ptl->general_inbld_flag); + else + rbsp_bit(rbsp, &ptl->general_reserved_zero_bit); + rbsp_bits(rbsp, 8, &ptl->general_level_idc); + if (max_num_sub_layers_minus_1 > 0) + rbsp_unsupported(rbsp); +} + +static void nal_hevc_rbsp_vps(struct rbsp *rbsp, struct nal_hevc_vps *vps) +{ + unsigned int i, j; + unsigned int reserved_0xffff_16bits = 0xffff; + + rbsp_bits(rbsp, 4, &vps->video_parameter_set_id); + rbsp_bit(rbsp, &vps->base_layer_internal_flag); + rbsp_bit(rbsp, &vps->base_layer_available_flag); + rbsp_bits(rbsp, 6, &vps->max_layers_minus1); + rbsp_bits(rbsp, 3, &vps->max_sub_layers_minus1); + rbsp_bits(rbsp, 1, &vps->temporal_id_nesting_flag); + rbsp_bits(rbsp, 16, &reserved_0xffff_16bits); + nal_hevc_rbsp_profile_tier_level(rbsp, &vps->profile_tier_level); + rbsp_bit(rbsp, &vps->sub_layer_ordering_info_present_flag); + for (i = vps->sub_layer_ordering_info_present_flag ? 0 : vps->max_sub_layers_minus1; + i <= vps->max_sub_layers_minus1; i++) { + rbsp_uev(rbsp, &vps->max_dec_pic_buffering_minus1[i]); + rbsp_uev(rbsp, &vps->max_num_reorder_pics[i]); + rbsp_uev(rbsp, &vps->max_latency_increase_plus1[i]); + } + rbsp_bits(rbsp, 6, &vps->max_layer_id); + rbsp_uev(rbsp, &vps->num_layer_sets_minus1); + for (i = 0; i <= vps->num_layer_sets_minus1; i++) + for (j = 0; j <= vps->max_layer_id; j++) + rbsp_bit(rbsp, &vps->layer_id_included_flag[i][j]); + rbsp_bit(rbsp, &vps->timing_info_present_flag); + if (vps->timing_info_present_flag) + rbsp_unsupported(rbsp); + rbsp_bit(rbsp, &vps->extension_flag); + if (vps->extension_flag) + rbsp_unsupported(rbsp); +} + +static void nal_hevc_rbsp_sps(struct rbsp *rbsp, struct nal_hevc_sps *sps) +{ + unsigned int i; + + rbsp_bits(rbsp, 4, &sps->video_parameter_set_id); + rbsp_bits(rbsp, 3, &sps->max_sub_layers_minus1); + rbsp_bit(rbsp, &sps->temporal_id_nesting_flag); + nal_hevc_rbsp_profile_tier_level(rbsp, &sps->profile_tier_level); + rbsp_uev(rbsp, &sps->seq_parameter_set_id); + + rbsp_uev(rbsp, &sps->chroma_format_idc); + if (sps->chroma_format_idc == 3) + rbsp_bit(rbsp, &sps->separate_colour_plane_flag); + rbsp_uev(rbsp, &sps->pic_width_in_luma_samples); + rbsp_uev(rbsp, &sps->pic_height_in_luma_samples); + rbsp_bit(rbsp, &sps->conformance_window_flag); + if (sps->conformance_window_flag) { + rbsp_uev(rbsp, &sps->conf_win_left_offset); + rbsp_uev(rbsp, &sps->conf_win_right_offset); + rbsp_uev(rbsp, &sps->conf_win_top_offset); + rbsp_uev(rbsp, &sps->conf_win_bottom_offset); + } + rbsp_uev(rbsp, &sps->bit_depth_luma_minus8); + rbsp_uev(rbsp, &sps->bit_depth_chroma_minus8); + + rbsp_uev(rbsp, &sps->log2_max_pic_order_cnt_lsb_minus4); + + rbsp_bit(rbsp, &sps->sub_layer_ordering_info_present_flag); + for (i = (sps->sub_layer_ordering_info_present_flag ? 0 : sps->max_sub_layers_minus1); + i <= sps->max_sub_layers_minus1; i++) { + rbsp_uev(rbsp, &sps->max_dec_pic_buffering_minus1[i]); + rbsp_uev(rbsp, &sps->max_num_reorder_pics[i]); + rbsp_uev(rbsp, &sps->max_latency_increase_plus1[i]); + } + rbsp_uev(rbsp, &sps->log2_min_luma_coding_block_size_minus3); + rbsp_uev(rbsp, &sps->log2_diff_max_min_luma_coding_block_size); + rbsp_uev(rbsp, &sps->log2_min_luma_transform_block_size_minus2); + rbsp_uev(rbsp, &sps->log2_diff_max_min_luma_transform_block_size); + rbsp_uev(rbsp, &sps->max_transform_hierarchy_depth_inter); + rbsp_uev(rbsp, &sps->max_transform_hierarchy_depth_intra); + + rbsp_bit(rbsp, &sps->scaling_list_enabled_flag); + if (sps->scaling_list_enabled_flag) + rbsp_unsupported(rbsp); + + rbsp_bit(rbsp, &sps->amp_enabled_flag); + rbsp_bit(rbsp, &sps->sample_adaptive_offset_enabled_flag); + rbsp_bit(rbsp, &sps->pcm_enabled_flag); + if (sps->pcm_enabled_flag) { + rbsp_bits(rbsp, 4, &sps->pcm_sample_bit_depth_luma_minus1); + rbsp_bits(rbsp, 4, &sps->pcm_sample_bit_depth_chroma_minus1); + rbsp_uev(rbsp, &sps->log2_min_pcm_luma_coding_block_size_minus3); + rbsp_uev(rbsp, &sps->log2_diff_max_min_pcm_luma_coding_block_size); + rbsp_bit(rbsp, &sps->pcm_loop_filter_disabled_flag); + } + + rbsp_uev(rbsp, &sps->num_short_term_ref_pic_sets); + if (sps->num_short_term_ref_pic_sets > 0) + rbsp_unsupported(rbsp); + + rbsp_bit(rbsp, &sps->long_term_ref_pics_present_flag); + if (sps->long_term_ref_pics_present_flag) + rbsp_unsupported(rbsp); + + rbsp_bit(rbsp, &sps->sps_temporal_mvp_enabled_flag); + rbsp_bit(rbsp, &sps->strong_intra_smoothing_enabled_flag); + rbsp_bit(rbsp, &sps->vui_parameters_present_flag); + if (sps->vui_parameters_present_flag) + rbsp_unsupported(rbsp); + + rbsp_bit(rbsp, &sps->extension_present_flag); + if (sps->extension_present_flag) { + rbsp_bit(rbsp, &sps->sps_range_extension_flag); + rbsp_bit(rbsp, &sps->sps_multilayer_extension_flag); + rbsp_bit(rbsp, &sps->sps_3d_extension_flag); + rbsp_bit(rbsp, &sps->sps_scc_extension_flag); + rbsp_bits(rbsp, 5, &sps->sps_extension_4bits); + } + if (sps->sps_range_extension_flag) + rbsp_unsupported(rbsp); + if (sps->sps_multilayer_extension_flag) + rbsp_unsupported(rbsp); + if (sps->sps_3d_extension_flag) + rbsp_unsupported(rbsp); + if (sps->sps_scc_extension_flag) + rbsp_unsupported(rbsp); + if (sps->sps_extension_4bits) + rbsp_unsupported(rbsp); +} + +static void nal_hevc_rbsp_pps(struct rbsp *rbsp, struct nal_hevc_pps *pps) +{ + unsigned int i; + + rbsp_uev(rbsp, &pps->pps_pic_parameter_set_id); + rbsp_uev(rbsp, &pps->pps_seq_parameter_set_id); + rbsp_bit(rbsp, &pps->dependent_slice_segments_enabled_flag); + rbsp_bit(rbsp, &pps->output_flag_present_flag); + rbsp_bits(rbsp, 3, &pps->num_extra_slice_header_bits); + rbsp_bit(rbsp, &pps->sign_data_hiding_enabled_flag); + rbsp_bit(rbsp, &pps->cabac_init_present_flag); + rbsp_uev(rbsp, &pps->num_ref_idx_l0_default_active_minus1); + rbsp_uev(rbsp, &pps->num_ref_idx_l1_default_active_minus1); + rbsp_sev(rbsp, &pps->init_qp_minus26); + rbsp_bit(rbsp, &pps->constrained_intra_pred_flag); + rbsp_bit(rbsp, &pps->transform_skip_enabled_flag); + rbsp_bit(rbsp, &pps->cu_qp_delta_enabled_flag); + if (pps->cu_qp_delta_enabled_flag) + rbsp_uev(rbsp, &pps->diff_cu_qp_delta_depth); + rbsp_sev(rbsp, &pps->pps_cb_qp_offset); + rbsp_sev(rbsp, &pps->pps_cr_qp_offset); + rbsp_bit(rbsp, &pps->pps_slice_chroma_qp_offsets_present_flag); + rbsp_bit(rbsp, &pps->weighted_pred_flag); + rbsp_bit(rbsp, &pps->weighted_bipred_flag); + rbsp_bit(rbsp, &pps->transquant_bypass_enabled_flag); + rbsp_bit(rbsp, &pps->tiles_enabled_flag); + rbsp_bit(rbsp, &pps->entropy_coding_sync_enabled_flag); + if (pps->tiles_enabled_flag) { + rbsp_uev(rbsp, &pps->num_tile_columns_minus1); + rbsp_uev(rbsp, &pps->num_tile_rows_minus1); + rbsp_bit(rbsp, &pps->uniform_spacing_flag); + if (!pps->uniform_spacing_flag) { + for (i = 0; i < pps->num_tile_columns_minus1; i++) + rbsp_uev(rbsp, &pps->column_width_minus1[i]); + for (i = 0; i < pps->num_tile_rows_minus1; i++) + rbsp_uev(rbsp, &pps->row_height_minus1[i]); + } + rbsp_bit(rbsp, &pps->loop_filter_across_tiles_enabled_flag); + } + rbsp_bit(rbsp, &pps->pps_loop_filter_across_slices_enabled_flag); + rbsp_bit(rbsp, &pps->deblocking_filter_control_present_flag); + if (pps->deblocking_filter_control_present_flag) { + rbsp_bit(rbsp, &pps->deblocking_filter_override_enabled_flag); + rbsp_bit(rbsp, &pps->pps_deblocking_filter_disabled_flag); + if (!pps->pps_deblocking_filter_disabled_flag) { + rbsp_sev(rbsp, &pps->pps_beta_offset_div2); + rbsp_sev(rbsp, &pps->pps_tc_offset_div2); + } + } + rbsp_bit(rbsp, &pps->pps_scaling_list_data_present_flag); + if (pps->pps_scaling_list_data_present_flag) + rbsp_unsupported(rbsp); + rbsp_bit(rbsp, &pps->lists_modification_present_flag); + rbsp_uev(rbsp, &pps->log2_parallel_merge_level_minus2); + rbsp_bit(rbsp, &pps->slice_segment_header_extension_present_flag); + rbsp_bit(rbsp, &pps->pps_extension_present_flag); + if (pps->pps_extension_present_flag) { + rbsp_bit(rbsp, &pps->pps_range_extension_flag); + rbsp_bit(rbsp, &pps->pps_multilayer_extension_flag); + rbsp_bit(rbsp, &pps->pps_3d_extension_flag); + rbsp_bit(rbsp, &pps->pps_scc_extension_flag); + rbsp_bits(rbsp, 4, &pps->pps_extension_4bits); + } + if (pps->pps_range_extension_flag) + rbsp_unsupported(rbsp); + if (pps->pps_multilayer_extension_flag) + rbsp_unsupported(rbsp); + if (pps->pps_3d_extension_flag) + rbsp_unsupported(rbsp); + if (pps->pps_scc_extension_flag) + rbsp_unsupported(rbsp); + if (pps->pps_extension_4bits) + rbsp_unsupported(rbsp); +} + +/** + * nal_hevc_write_vps() - write pps nal unit into rbsp format + * @dev: device pointer + * @dest: the buffer that is filled with rbsp data + * @n: maximum size of @dest in bytes + * @vps: &struct nal_hevc_vps to convert to rbsp + * + * convert @vps to rbsp data and write it into @dest. + * + * the size of the vps nal unit is not known in advance and this function will + * fail, if @dest does not hold sufficient space for the vps nal unit. + * + * return: number of bytes written to @dest or negative error code + */ +ssize_t nal_hevc_write_vps(const struct device *dev, + void *dest, size_t n, struct nal_hevc_vps *vps) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit = 0; + unsigned int nal_unit_type = vps_nut; + unsigned int nuh_layer_id = 0; + unsigned int nuh_temporal_id_plus1 = 1; + + if (!dest) + return -einval; + + rbsp_init(&rbsp, dest, n, &write); + + nal_hevc_write_start_code_prefix(&rbsp); + + /* nal unit header */ + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + nal_hevc_rbsp_vps(&rbsp, vps); + + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_write_vps); + +/** + * nal_hevc_read_vps() - read vps nal unit from rbsp format + * @dev: device pointer + * @vps: the &struct nal_hevc_vps to fill from the rbsp data + * @src: the buffer that contains the rbsp data + * @n: size of @src in bytes + * + * read rbsp data from @src and use it to fill @vps. + * + * return: number of bytes read from @src or negative error code + */ +ssize_t nal_hevc_read_vps(const struct device *dev, + struct nal_hevc_vps *vps, void *src, size_t n) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit; + unsigned int nal_unit_type; + unsigned int nuh_layer_id; + unsigned int nuh_temporal_id_plus1; + + if (!src) + return -einval; + + rbsp_init(&rbsp, src, n, &read); + + nal_hevc_read_start_code_prefix(&rbsp); + + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + if (rbsp.error || + forbidden_zero_bit != 0 || + nal_unit_type != vps_nut) + return -einval; + + nal_hevc_rbsp_vps(&rbsp, vps); + + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_read_vps); + +/** + * nal_hevc_write_sps() - write sps nal unit into rbsp format + * @dev: device pointer + * @dest: the buffer that is filled with rbsp data + * @n: maximum size of @dest in bytes + * @sps: &struct nal_hevc_sps to convert to rbsp + * + * convert @sps to rbsp data and write it into @dest. + * + * the size of the sps nal unit is not known in advance and this function will + * fail, if @dest does not hold sufficient space for the sps nal unit. + * + * return: number of bytes written to @dest or negative error code + */ +ssize_t nal_hevc_write_sps(const struct device *dev, + void *dest, size_t n, struct nal_hevc_sps *sps) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit = 0; + unsigned int nal_unit_type = sps_nut; + unsigned int nuh_layer_id = 0; + unsigned int nuh_temporal_id_plus1 = 1; + + if (!dest) + return -einval; + + rbsp_init(&rbsp, dest, n, &write); + + nal_hevc_write_start_code_prefix(&rbsp); + + /* nal unit header */ + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + nal_hevc_rbsp_sps(&rbsp, sps); + + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_write_sps); + +/** + * nal_hevc_read_sps() - read sps nal unit from rbsp format + * @dev: device pointer + * @sps: the &struct nal_hevc_sps to fill from the rbsp data + * @src: the buffer that contains the rbsp data + * @n: size of @src in bytes + * + * read rbsp data from @src and use it to fill @sps. + * + * return: number of bytes read from @src or negative error code + */ +ssize_t nal_hevc_read_sps(const struct device *dev, + struct nal_hevc_sps *sps, void *src, size_t n) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit; + unsigned int nal_unit_type; + unsigned int nuh_layer_id; + unsigned int nuh_temporal_id_plus1; + + if (!src) + return -einval; + + rbsp_init(&rbsp, src, n, &read); + + nal_hevc_read_start_code_prefix(&rbsp); + + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + if (rbsp.error || + forbidden_zero_bit != 0 || + nal_unit_type != sps_nut) + return -einval; + + nal_hevc_rbsp_sps(&rbsp, sps); + + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_read_sps); + +/** + * nal_hevc_write_pps() - write pps nal unit into rbsp format + * @dev: device pointer + * @dest: the buffer that is filled with rbsp data + * @n: maximum size of @dest in bytes + * @pps: &struct nal_hevc_pps to convert to rbsp + * + * convert @pps to rbsp data and write it into @dest. + * + * the size of the pps nal unit is not known in advance and this function will + * fail, if @dest does not hold sufficient space for the pps nal unit. + * + * return: number of bytes written to @dest or negative error code + */ +ssize_t nal_hevc_write_pps(const struct device *dev, + void *dest, size_t n, struct nal_hevc_pps *pps) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit = 0; + unsigned int nal_unit_type = pps_nut; + unsigned int nuh_layer_id = 0; + unsigned int nuh_temporal_id_plus1 = 1; + + if (!dest) + return -einval; + + rbsp_init(&rbsp, dest, n, &write); + + nal_hevc_write_start_code_prefix(&rbsp); + + /* nal unit header */ + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + nal_hevc_rbsp_pps(&rbsp, pps); + + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_write_pps); + +/** + * nal_hevc_read_pps() - read pps nal unit from rbsp format + * @dev: device pointer + * @pps: the &struct nal_hevc_pps to fill from the rbsp data + * @src: the buffer that contains the rbsp data + * @n: size of @src in bytes + * + * read rbsp data from @src and use it to fill @pps. + * + * return: number of bytes read from @src or negative error code + */ +ssize_t nal_hevc_read_pps(const struct device *dev, + struct nal_hevc_pps *pps, void *src, size_t n) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit; + unsigned int nal_unit_type; + unsigned int nuh_layer_id; + unsigned int nuh_temporal_id_plus1; + + if (!src) + return -einval; + + rbsp_init(&rbsp, src, n, &read); + + nal_hevc_read_start_code_prefix(&rbsp); + + /* nal unit header */ + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + nal_hevc_rbsp_pps(&rbsp, pps); + + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_read_pps); + +/** + * nal_hevc_write_filler() - write filler data rbsp + * @dev: device pointer + * @dest: buffer to fill with filler data + * @n: size of the buffer to fill with filler data + * + * write a filler data rbsp to @dest with a size of @n bytes and return the + * number of written filler data bytes. + * + * use this function to generate dummy data in an rbsp data stream that can be + * safely ignored by hevc decoders. + * + * the rbsp format of the filler data is specified in rec. itu-t h.265 + * (02/2018) 7.3.2.8 filler data rbsp syntax. + * + * return: number of filler data bytes (including marker) or negative error + */ +ssize_t nal_hevc_write_filler(const struct device *dev, void *dest, size_t n) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit = 0; + unsigned int nal_unit_type = fd_nut; + unsigned int nuh_layer_id = 0; + unsigned int nuh_temporal_id_plus1 = 1; + + if (!dest) + return -einval; + + rbsp_init(&rbsp, dest, n, &write); + + nal_hevc_write_start_code_prefix(&rbsp); + + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + nal_hevc_write_filler_data(&rbsp); + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_write_filler); + +/** + * nal_hevc_read_filler() - read filler data rbsp + * @dev: device pointer + * @src: buffer with rbsp data that is read + * @n: maximum size of src that shall be read + * + * read a filler data rbsp from @src up to a maximum size of @n bytes and + * return the size of the filler data in bytes including the marker. + * + * this function is used to parse filler data and skip the respective bytes in + * the rbsp data. + * + * the rbsp format of the filler data is specified in rec. itu-t h.265 + * (02/2018) 7.3.2.8 filler data rbsp syntax. + * + * return: number of filler data bytes (including marker) or negative error + */ +ssize_t nal_hevc_read_filler(const struct device *dev, void *src, size_t n) +{ + struct rbsp rbsp; + unsigned int forbidden_zero_bit; + unsigned int nal_unit_type; + unsigned int nuh_layer_id; + unsigned int nuh_temporal_id_plus1; + + if (!src) + return -einval; + + rbsp_init(&rbsp, src, n, &read); + + nal_hevc_read_start_code_prefix(&rbsp); + + rbsp_bit(&rbsp, &forbidden_zero_bit); + rbsp_bits(&rbsp, 6, &nal_unit_type); + rbsp_bits(&rbsp, 6, &nuh_layer_id); + rbsp_bits(&rbsp, 3, &nuh_temporal_id_plus1); + + if (rbsp.error) + return rbsp.error; + if (forbidden_zero_bit != 0 || + nal_unit_type != fd_nut) + return -einval; + + nal_hevc_read_filler_data(&rbsp); + rbsp_trailing_bits(&rbsp); + + if (rbsp.error) + return rbsp.error; + + return div_round_up(rbsp.pos, 8); +} +export_symbol_gpl(nal_hevc_read_filler); diff --git a/drivers/media/platform/allegro-dvt/nal-hevc.h b/drivers/media/platform/allegro-dvt/nal-hevc.h --- /dev/null +++ b/drivers/media/platform/allegro-dvt/nal-hevc.h +/* spdx-license-identifier: gpl-2.0 */ +/* + * copyright (c) 2019 pengutronix, michael tretter <kernel@pengutronix.de> + * + * convert nal units between raw byte sequence payloads (rbsp) and c structs. + */ + +#ifndef __nal_hevc_h__ +#define __nal_hevc_h__ + +#include <linux/kernel.h> +#include <linux/types.h> +#include <media/v4l2-ctrls.h> + +struct nal_hevc_profile_tier_level { + unsigned int general_profile_space; + unsigned int general_tier_flag; + unsigned int general_profile_idc; + unsigned int general_profile_compatibility_flag[32]; + unsigned int general_progressive_source_flag; + unsigned int general_interlaced_source_flag; + unsigned int general_non_packed_constraint_flag; + unsigned int general_frame_only_constraint_flag; + union { + struct { + unsigned int general_max_12bit_constraint_flag; + unsigned int general_max_10bit_constraint_flag; + unsigned int general_max_8bit_constraint_flag; + unsigned int general_max_422chroma_constraint_flag; + unsigned int general_max_420chroma_constraint_flag; + unsigned int general_max_monochrome_constraint_flag; + unsigned int general_intra_constraint_flag; + unsigned int general_one_picture_only_constraint_flag; + unsigned int general_lower_bit_rate_constraint_flag; + union { + struct { + unsigned int general_max_14bit_constraint_flag; + unsigned int general_reserved_zero_33bits; + }; + unsigned int general_reserved_zero_34bits; + }; + }; + struct { + unsigned int general_reserved_zero_7bits; + /* unsigned int general_one_picture_only_constraint_flag; */ + unsigned int general_reserved_zero_35bits; + }; + unsigned int general_reserved_zero_43bits; + }; + union { + unsigned int general_inbld_flag; + unsigned int general_reserved_zero_bit; + }; + unsigned int general_level_idc; +}; + +/** + * struct nal_hevc_vps - video parameter set + * + * c struct representation of the video parameter set nal unit as defined by + * rec. itu-t h.265 (02/2018) 7.3.2.1 video parameter set rbsp syntax + */ +struct nal_hevc_vps { + unsigned int video_parameter_set_id; + unsigned int base_layer_internal_flag; + unsigned int base_layer_available_flag; + unsigned int max_layers_minus1; + unsigned int max_sub_layers_minus1; + unsigned int temporal_id_nesting_flag; + struct nal_hevc_profile_tier_level profile_tier_level; + unsigned int sub_layer_ordering_info_present_flag; + struct { + unsigned int max_dec_pic_buffering_minus1[7]; + unsigned int max_num_reorder_pics[7]; + unsigned int max_latency_increase_plus1[7]; + }; + unsigned int max_layer_id; + unsigned int num_layer_sets_minus1; + unsigned int layer_id_included_flag[1024][64]; + unsigned int timing_info_present_flag; + struct { + unsigned int num_units_in_tick; + unsigned int time_scale; + unsigned int poc_proportional_to_timing_flag; + unsigned int num_ticks_poc_diff_one_minus1; + unsigned int num_hrd_parameters; + struct { + unsigned int hrd_layer_set_idx[0]; + unsigned int cprms_present_flag[0]; + }; + /* hrd_parameters( cprms_present_flag[ i ], max_sub_layers_minus1 ) */ + }; + unsigned int extension_flag; + unsigned int extension_data_flag; +}; + +struct nal_hevc_sub_layer_hrd_parameters { + unsigned int bit_rate_value_minus1[1]; + unsigned int cpb_size_value_minus1[1]; + unsigned int cbr_flag[1]; +}; + +struct nal_hevc_hrd_parameters { + unsigned int nal_hrd_parameters_present_flag; + unsigned int vcl_hrd_parameters_present_flag; + struct { + unsigned int sub_pic_hrd_params_present_flag; + struct { + unsigned int tick_divisor_minus2; + unsigned int du_cpb_removal_delay_increment_length_minus1; + unsigned int sub_pic_cpb_params_in_pic_timing_sei_flag; + unsigned int dpb_output_delay_du_length_minus1; + }; + unsigned int bit_rate_scale; + unsigned int cpb_size_scale; + unsigned int cpb_size_du_scale; + unsigned int initial_cpb_removal_delay_length_minus1; + unsigned int au_cpb_removal_delay_length_minus1; + unsigned int dpb_output_delay_length_minus1; + }; + struct { + unsigned int fixed_pic_rate_general_flag[1]; + unsigned int fixed_pic_rate_within_cvs_flag[1]; + unsigned int elemental_duration_in_tc_minus1[1]; + unsigned int low_delay_hrd_flag[1]; + unsigned int cpb_cnt_minus1[1]; + struct nal_hevc_sub_layer_hrd_parameters nal_hrd[1]; + struct nal_hevc_sub_layer_hrd_parameters vcl_hrd[1]; + }; +}; + +/** + * struct nal_hevc_vui_parameters - vui parameters + * + * c struct representation of the vui parameters as defined by rec. itu-t + * h.265 (02/2018) e.2.1 vui parameters syntax. + */ +struct nal_hevc_vui_parameters { + unsigned int aspect_ratio_info_present_flag; + struct { + unsigned int aspect_ratio_idc; + unsigned int sar_width; + unsigned int sar_height; + }; + unsigned int overscan_info_present_flag; + unsigned int overscan_appropriate_flag; + unsigned int video_signal_type_present_flag; + struct { + unsigned int video_format; + unsigned int video_full_range_flag; + unsigned int colour_description_present_flag; + struct { + unsigned int colour_primaries; + unsigned int transfer_characteristics; + unsigned int matrix_coeffs; + }; + }; + unsigned int chroma_loc_info_present_flag; + struct { + unsigned int chroma_sample_loc_type_top_field; + unsigned int chroma_sample_loc_type_bottom_field; + }; + unsigned int neutral_chroma_indication_flag; + unsigned int field_seq_flag; + unsigned int frame_field_info_present_flag; + unsigned int default_display_window_flag; + struct { + unsigned int def_disp_win_left_offset; + unsigned int def_disp_win_right_offset; + unsigned int def_disp_win_top_offset; + unsigned int def_disp_win_bottom_offset; + }; + unsigned int vui_timing_info_present_flag; + struct { + unsigned int vui_num_units_in_tick; + unsigned int vui_time_scale; + unsigned int vui_poc_proportional_to_timing_flag; + unsigned int vui_num_ticks_poc_diff_one_minus1; + unsigned int vui_hrd_parameters_present_flag; + struct nal_hevc_hrd_parameters nal_hrd_parameters; + }; + unsigned int bitstream_restriction_flag; + struct { + unsigned int tiles_fixed_structure_flag; + unsigned int motion_vectors_over_pic_boundaries_flag; + unsigned int restricted_ref_pic_lists_flag; + unsigned int min_spatial_segmentation_idc; + unsigned int max_bytes_per_pic_denom; + unsigned int max_bits_per_min_cu_denom; + unsigned int log2_max_mv_length_horizontal; + unsigned int log2_max_mv_length_vertical; + }; +}; + +/** + * struct nal_hevc_sps - sequence parameter set + * + * c struct representation of the video parameter set nal unit as defined by + * rec. itu-t h.265 (02/2018) 7.3.2.2 sequence parameter set rbsp syntax + */ +struct nal_hevc_sps { + unsigned int video_parameter_set_id; + unsigned int max_sub_layers_minus1; + unsigned int temporal_id_nesting_flag; + struct nal_hevc_profile_tier_level profile_tier_level; + unsigned int seq_parameter_set_id; + unsigned int chroma_format_idc; + unsigned int separate_colour_plane_flag; + unsigned int pic_width_in_luma_samples; + unsigned int pic_height_in_luma_samples; + unsigned int conformance_window_flag; + struct { + unsigned int conf_win_left_offset; + unsigned int conf_win_right_offset; + unsigned int conf_win_top_offset; + unsigned int conf_win_bottom_offset; + }; + + unsigned int bit_depth_luma_minus8; + unsigned int bit_depth_chroma_minus8; + unsigned int log2_max_pic_order_cnt_lsb_minus4; + unsigned int sub_layer_ordering_info_present_flag; + struct { + unsigned int max_dec_pic_buffering_minus1[7]; + unsigned int max_num_reorder_pics[7]; + unsigned int max_latency_increase_plus1[7]; + }; + unsigned int log2_min_luma_coding_block_size_minus3; + unsigned int log2_diff_max_min_luma_coding_block_size; + unsigned int log2_min_luma_transform_block_size_minus2; + unsigned int log2_diff_max_min_luma_transform_block_size; + unsigned int max_transform_hierarchy_depth_inter; + unsigned int max_transform_hierarchy_depth_intra; + + unsigned int scaling_list_enabled_flag; + unsigned int scaling_list_data_present_flag; + unsigned int amp_enabled_flag; + unsigned int sample_adaptive_offset_enabled_flag; + unsigned int pcm_enabled_flag; + struct { + unsigned int pcm_sample_bit_depth_luma_minus1; + unsigned int pcm_sample_bit_depth_chroma_minus1; + unsigned int log2_min_pcm_luma_coding_block_size_minus3; + unsigned int log2_diff_max_min_pcm_luma_coding_block_size; + unsigned int pcm_loop_filter_disabled_flag; + }; + + unsigned int num_short_term_ref_pic_sets; + unsigned int long_term_ref_pics_present_flag; + unsigned int sps_temporal_mvp_enabled_flag; + unsigned int strong_intra_smoothing_enabled_flag; + unsigned int vui_parameters_present_flag; + struct nal_hevc_vui_parameters vui; + unsigned int extension_present_flag; + struct { + unsigned int sps_range_extension_flag; + unsigned int sps_multilayer_extension_flag; + unsigned int sps_3d_extension_flag; + unsigned int sps_scc_extension_flag; + unsigned int sps_extension_4bits; + }; +}; + +struct nal_hevc_pps { + unsigned int pps_pic_parameter_set_id; + unsigned int pps_seq_parameter_set_id; + unsigned int dependent_slice_segments_enabled_flag; + unsigned int output_flag_present_flag; + unsigned int num_extra_slice_header_bits; + unsigned int sign_data_hiding_enabled_flag; + unsigned int cabac_init_present_flag; + unsigned int num_ref_idx_l0_default_active_minus1; + unsigned int num_ref_idx_l1_default_active_minus1; + int init_qp_minus26; + unsigned int constrained_intra_pred_flag; + unsigned int transform_skip_enabled_flag; + unsigned int cu_qp_delta_enabled_flag; + unsigned int diff_cu_qp_delta_depth; + int pps_cb_qp_offset; + int pps_cr_qp_offset; + unsigned int pps_slice_chroma_qp_offsets_present_flag; + unsigned int weighted_pred_flag; + unsigned int weighted_bipred_flag; + unsigned int transquant_bypass_enabled_flag; + unsigned int tiles_enabled_flag; + unsigned int entropy_coding_sync_enabled_flag; + struct { + unsigned int num_tile_columns_minus1; + unsigned int num_tile_rows_minus1; + unsigned int uniform_spacing_flag; + struct { + unsigned int column_width_minus1[1]; + unsigned int row_height_minus1[1]; + }; + unsigned int loop_filter_across_tiles_enabled_flag; + }; + unsigned int pps_loop_filter_across_slices_enabled_flag; + unsigned int deblocking_filter_control_present_flag; + struct { + unsigned int deblocking_filter_override_enabled_flag; + unsigned int pps_deblocking_filter_disabled_flag; + struct { + int pps_beta_offset_div2; + int pps_tc_offset_div2; + }; + }; + unsigned int pps_scaling_list_data_present_flag; + unsigned int lists_modification_present_flag; + unsigned int log2_parallel_merge_level_minus2; + unsigned int slice_segment_header_extension_present_flag; + unsigned int pps_extension_present_flag; + struct { + unsigned int pps_range_extension_flag; + unsigned int pps_multilayer_extension_flag; + unsigned int pps_3d_extension_flag; + unsigned int pps_scc_extension_flag; + unsigned int pps_extension_4bits; + }; +}; + +int nal_hevc_profile_from_v4l2(enum v4l2_mpeg_video_hevc_profile profile); +int nal_hevc_tier_from_v4l2(enum v4l2_mpeg_video_hevc_tier tier); +int nal_hevc_level_from_v4l2(enum v4l2_mpeg_video_hevc_level level); + +int nal_range_from_v4l2(enum v4l2_quantization quantization); +int nal_color_primaries_from_v4l2(enum v4l2_colorspace colorspace); +int nal_transfer_characteristics_from_v4l2(enum v4l2_colorspace colorspace, + enum v4l2_xfer_func xfer_func); +int nal_matrix_coeffs_from_v4l2(enum v4l2_colorspace colorspace, + enum v4l2_ycbcr_encoding ycbcr_encoding); + +ssize_t nal_hevc_write_vps(const struct device *dev, + void *dest, size_t n, struct nal_hevc_vps *vps); +ssize_t nal_hevc_read_vps(const struct device *dev, + struct nal_hevc_vps *vps, void *src, size_t n); + +ssize_t nal_hevc_write_sps(const struct device *dev, + void *dest, size_t n, struct nal_hevc_sps *sps); +ssize_t nal_hevc_read_sps(const struct device *dev, + struct nal_hevc_sps *sps, void *src, size_t n); + +ssize_t nal_hevc_write_pps(const struct device *dev, + void *dest, size_t n, struct nal_hevc_pps *pps); +ssize_t nal_hevc_read_pps(const struct device *dev, + struct nal_hevc_pps *pps, void *src, size_t n); + +ssize_t nal_hevc_write_filler(const struct device *dev, void *dest, size_t n); +ssize_t nal_hevc_read_filler(const struct device *dev, void *src, size_t n); + +#endif /* __nal_hevc_h__ */
TV tuners, webcams, video capturers
7f8e438b90c91541d784feb5f71be1a0b01a6010
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: implement s_fmt for capture
in order to support different codecs, the driver must support changing the format on capture. therefore, the driver needs to handle s_fmt on capture.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
27
3
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c - if (f->index) - return -einval; + if (f->index >= 1) + return -einval; + if (f->index >= 1) + return -einval; +static int allegro_s_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) +{ + struct allegro_channel *channel = fh_to_channel(fh); + struct vb2_queue *vq; + int err; + + err = allegro_try_fmt_vid_cap(file, fh, f); + if (err) + return err; + + vq = v4l2_m2m_get_vq(channel->fh.m2m_ctx, f->type); + if (!vq) + return -einval; + if (vb2_is_busy(vq)) + return -ebusy; + + channel->codec = f->fmt.pix.pixelformat; + + return 0; +} + - .vidioc_s_fmt_vid_cap = allegro_try_fmt_vid_cap, + .vidioc_s_fmt_vid_cap = allegro_s_fmt_vid_cap,
TV tuners, webcams, video capturers
8e64f00846bb19cb1910363c1acad64aa92020d4
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: adjust channel after format change
a format change (i.e. the frame size or the codec) has multiple effects on a channel:
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
52
17
- the available controls - the limits of the available controls - the default encoding options --- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c - enum v4l2_mpeg_video_h264_level min_level; - min_level = select_minimum_h264_level(channel->width, channel->height); - if (channel->level < min_level) { - v4l2_warn(&dev->v4l2_dev, - "user %d: selected level %s too low: increasing to level %s ", - channel->user_id, - v4l2_ctrl_get_menu(v4l2_cid_mpeg_video_h264_level)[channel->level], - v4l2_ctrl_get_menu(v4l2_cid_mpeg_video_h264_level)[min_level]); - channel->level = min_level; - } - +/** + * allegro_channel_adjust() - adjust channel parameters to current format + * @channel: the channel to adjust + * + * various parameters of a channel and their limits depend on the currently + * set format. adjust the parameters after a format change in one go. + */ +static void allegro_channel_adjust(struct allegro_channel *channel) +{ + struct allegro_dev *dev = channel->dev; + struct v4l2_ctrl *ctrl; + s64 min; + s64 max; + + channel->sizeimage_encoded = + estimate_stream_size(channel->width, channel->height); + + ctrl = channel->mpeg_video_h264_level; + min = select_minimum_h264_level(channel->width, channel->height); + if (ctrl->minimum > min) + v4l2_dbg(1, debug, &dev->v4l2_dev, + "%s.minimum: %lld -> %lld ", + v4l2_ctrl_get_name(ctrl->id), ctrl->minimum, min); + v4l2_ctrl_lock(ctrl); + __v4l2_ctrl_modify_range(ctrl, min, ctrl->maximum, + ctrl->step, ctrl->default_value); + v4l2_ctrl_unlock(ctrl); + channel->level = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level); + + ctrl = channel->mpeg_video_bitrate; + max = maximum_bitrate(v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level)); + if (ctrl->maximum < max) + v4l2_dbg(1, debug, &dev->v4l2_dev, + "%s: maximum: %lld -> %lld ", + v4l2_ctrl_get_name(ctrl->id), ctrl->maximum, max); + v4l2_ctrl_lock(ctrl); + __v4l2_ctrl_modify_range(ctrl, ctrl->minimum, max, + ctrl->step, ctrl->default_value); + v4l2_ctrl_unlock(ctrl); + + ctrl = channel->mpeg_video_bitrate_peak; + v4l2_ctrl_lock(ctrl); + __v4l2_ctrl_modify_range(ctrl, ctrl->minimum, max, + ctrl->step, ctrl->default_value); + v4l2_ctrl_unlock(ctrl); +} + - channel->sizeimage_encoded = - estimate_stream_size(channel->width, channel->height); + allegro_channel_adjust(channel); + + allegro_channel_adjust(channel); + - channel->level = - select_minimum_h264_level(channel->width, channel->height); - channel->sizeimage_encoded = - estimate_stream_size(channel->width, channel->height); + allegro_channel_adjust(channel);
TV tuners, webcams, video capturers
d2a1b58fd2df21d811872e4635087a91b6ba2d45
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: move encoding options to channel
there are several encoding options that are hard coded in the parameter that is used to configure the hardware codec. however, some of the options must be written to the sps/pps by the driver. furthermore, some of the options depend on the codec that is used (i.e. h.264 or hevc).
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
65
20
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c +/* encoding options */ +#define log2_max_frame_num 4 +#define log2_max_pic_order_cnt 10 +#define beta_offset_div_2 -1 +#define tc_offset_div_2 -1 + + unsigned int log2_max_frame_num; + bool temporal_mvp_enable; + + bool enable_loop_filter_across_tiles; + bool enable_loop_filter_across_slices; + bool dbf_ovr_en; + + /* maximum range for motion estimation */ + int b_hrz_me_range; + int b_vrt_me_range; + int p_hrz_me_range; + int p_vrt_me_range; + /* size limits of coding unit */ + int min_cu_size; + int max_cu_size; + /* size limits of transform unit */ + int min_tu_size; + int max_tu_size; + int max_transfo_depth_intra; + int max_transfo_depth_inter; + - param->log2_max_poc = 10; - param->log2_max_frame_num = 4; - param->temporal_mvp_enable = 1; + param->log2_max_poc = log2_max_pic_order_cnt; + param->log2_max_frame_num = channel->log2_max_frame_num; + param->temporal_mvp_enable = channel->temporal_mvp_enable; - param->dbf_ovr_en = 1; + param->dbf_ovr_en = channel->dbf_ovr_en; - param->lf_x_tile = 1; - param->lf_x_slice = 1; + param->lf_x_tile = channel->enable_loop_filter_across_tiles; + param->lf_x_slice = channel->enable_loop_filter_across_slices; - param->beta_offset = -1; - param->tc_offset = -1; + param->beta_offset = beta_offset_div_2; + param->tc_offset = tc_offset_div_2; - param->me_range[0] = 8; - param->me_range[1] = 8; - param->me_range[2] = 16; - param->me_range[3] = 16; - param->max_cu_size = ilog2(size_macroblock); - param->min_cu_size = ilog2(8); - param->max_tu_size = 2; - param->min_tu_size = 2; - param->max_transfo_depth_intra = 1; - param->max_transfo_depth_inter = 1; + param->me_range[0] = channel->b_hrz_me_range; + param->me_range[1] = channel->b_vrt_me_range; + param->me_range[2] = channel->p_hrz_me_range; + param->me_range[3] = channel->p_vrt_me_range; + param->max_cu_size = channel->max_cu_size; + param->min_cu_size = channel->min_cu_size; + param->max_tu_size = channel->max_tu_size; + param->min_tu_size = channel->min_tu_size; + param->max_transfo_depth_intra = channel->max_transfo_depth_intra; + param->max_transfo_depth_inter = channel->max_transfo_depth_inter; - sps->log2_max_frame_num_minus4 = 0; + sps->log2_max_frame_num_minus4 = log2_max_frame_num - 4; - sps->log2_max_pic_order_cnt_lsb_minus4 = 6; + sps->log2_max_pic_order_cnt_lsb_minus4 = log2_max_pic_order_cnt - 4; + + channel->log2_max_frame_num = log2_max_frame_num; + channel->temporal_mvp_enable = true; + + channel->dbf_ovr_en = true; + channel->enable_loop_filter_across_tiles = true; + channel->enable_loop_filter_across_slices = true; + + channel->b_hrz_me_range = 8; + channel->b_vrt_me_range = 8; + channel->p_hrz_me_range = 16; + channel->p_vrt_me_range = 16; + channel->max_cu_size = ilog2(16); + channel->min_cu_size = ilog2(8); + channel->max_tu_size = ilog2(4); + channel->min_tu_size = ilog2(4); + channel->max_transfo_depth_intra = 1; + channel->max_transfo_depth_inter = 1;
TV tuners, webcams, video capturers
83a4b7fd7f6f95da2905b7751cec4ad4dc6c222f
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: fix log2_max_poc in firmware 2019.1
the log2_max_poc field is used to set log2_max_pic_order_cnt_lsb_minus4 for the coded stream. it has an allowed range of 0 to 12.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
5
2
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-mail.c b/drivers/media/platform/allegro-dvt/allegro-mail.c --- a/drivers/media/platform/allegro-dvt/allegro-mail.c +++ b/drivers/media/platform/allegro-dvt/allegro-mail.c - val |= field_prep(genmask(7, 4), param->log2_max_frame_num) | - field_prep(genmask(3, 0), param->log2_max_poc); + val |= field_prep(genmask(7, 4), param->log2_max_frame_num); + if (version >= mcu_msg_version_2019_2) + val |= field_prep(genmask(3, 0), param->log2_max_poc - 1); + else + val |= field_prep(genmask(3, 0), param->log2_max_poc);
TV tuners, webcams, video capturers
e7cd90988b9d03c3a886a23f015c41c71371bc4f
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: use handler_setup to configure channel
v4l2_ctrl_handler_setup() calls s_ctrl for all controls of the handler. this ensures that the channel is initialized using the default values of the v4l2-ctrls.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
2
0
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c + v4l2_ctrl_handler_setup(handler); +
TV tuners, webcams, video capturers
21de56fa0789cf1c7e9a6d946f45c79ead04ffd4
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: initialize bitrate using v4l2_ctrl
as the driver now uses the v4l2-ctrls to setup the channel, there is no need to explicitly set the bitrate. the initial bitrate is now set via the same path as if it is set from userspace using the v4l2-ctrl.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
7
6
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c - channel->bitrate = maximum_bitrate(channel->level); - channel->bitrate_peak = maximum_bitrate(channel->level); + unsigned int bitrate_max; + unsigned int bitrate_def; + + bitrate_max = maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); + bitrate_def = maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); - 0, maximum_bitrate(v4l2_mpeg_video_h264_level_5_1), - 1, channel->bitrate); + 0, bitrate_max, 1, bitrate_def); - 0, maximum_bitrate(v4l2_mpeg_video_h264_level_5_1), - 1, channel->bitrate_peak); + 0, bitrate_max, 1, bitrate_def);
TV tuners, webcams, video capturers
2e3917e6bd226b2d69f903392592d701a388e4f0
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: implement scaling of cpb size in sps
the cbp_size_value_minus1 in the sps can scaled using cpb_size_scale to reduce the number of bits necessary to encode the value. for simplicity, the scaling was set to 1.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
6
2
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c + unsigned int cpb_size; + unsigned int cpb_size_scale; - sps->vui.vcl_hrd_parameters.cpb_size_scale = 1; + cpb_size = channel->cpb_size; + cpb_size_scale = ffs(cpb_size) - 4; + sps->vui.vcl_hrd_parameters.cpb_size_scale = cpb_size_scale; - (channel->cpb_size * 1000) / (1 << (4 + sps->vui.vcl_hrd_parameters.cpb_size_scale)) - 1; + (cpb_size * 1000) / (1 << (4 + cpb_size_scale)) - 1;
TV tuners, webcams, video capturers
d4a881c1b9f61978f05412487877b6745f58478d
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: remove cpb_size and gop_size from channel
the cpb_size and the gop_size are straight copies of the values in the v4l2-ctrls. to avoid this duplication, directly get the values from the v4l2-ctrls and remove the copies.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
11
19
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c - unsigned int cpb_size; - unsigned int gop_size; + unsigned int cpb_size = v4l2_ctrl_g_ctrl(channel->mpeg_video_cpb_size); - param->cpb_size = v4l2_cpb_size_to_mcu(channel->cpb_size, - channel->bitrate_peak); + param->cpb_size = v4l2_cpb_size_to_mcu(cpb_size, channel->bitrate_peak); - param->freq_idr = channel->gop_size; + param->freq_idr = v4l2_ctrl_g_ctrl(channel->mpeg_video_gop_size); - param->gop_length = channel->gop_size; + param->gop_length = v4l2_ctrl_g_ctrl(channel->mpeg_video_gop_size); - cpb_size = channel->cpb_size; + cpb_size = v4l2_ctrl_g_ctrl(channel->mpeg_video_cpb_size); - - channel->cpb_size = maximum_cpb_size(channel->level); - channel->gop_size = allegro_gop_size_default; - case v4l2_cid_mpeg_video_h264_cpb_size: - channel->cpb_size = ctrl->val; - break; - case v4l2_cid_mpeg_video_gop_size: - channel->gop_size = ctrl->val; - break; + unsigned int cpb_size_max; + unsigned int cpb_size_def; + cpb_size_max = maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); + cpb_size_def = maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); - 0, maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1), - 1, channel->cpb_size); + 0, cpb_size_max, 1, cpb_size_def); - 1, channel->gop_size); + 1, allegro_gop_size_default);
TV tuners, webcams, video capturers
7f046e4b05b382d6e1578b1963d79a1b68ee5be3
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: remove profile and level from channel
the profile and level are straight copies from the v4l2-ctrls. avoid duplication and directly read the value of the v4l2-ctrl.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
15
15
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c - enum v4l2_mpeg_video_h264_profile profile; - enum v4l2_mpeg_video_h264_level level; + enum v4l2_mpeg_video_h264_profile profile; + enum v4l2_mpeg_video_h264_level level; - param->profile = v4l2_profile_to_mcu_profile(channel->profile); - param->constraint_set_flags = bit(1); + - param->level = v4l2_level_to_mcu_level(channel->level); - param->tier = 0; + profile = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_profile); + level = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level); + param->profile = v4l2_profile_to_mcu_profile(profile); + param->constraint_set_flags = bit(1); + param->level = v4l2_level_to_mcu_level(level); + enum v4l2_mpeg_video_h264_profile profile; + enum v4l2_mpeg_video_h264_level level; - sps->profile_idc = nal_h264_profile_from_v4l2(channel->profile); + profile = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_profile); + level = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level); + + sps->profile_idc = nal_h264_profile_from_v4l2(profile); - sps->level_idc = nal_h264_level_from_v4l2(channel->level); + sps->level_idc = nal_h264_level_from_v4l2(level); - channel->level = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level); - channel->profile = v4l2_mpeg_video_h264_profile_baseline; - channel->level = - select_minimum_h264_level(channel->width, channel->height); - case v4l2_cid_mpeg_video_h264_level: - channel->level = ctrl->val; - break;
TV tuners, webcams, video capturers
608341075c2d5ead508962e837fb53a25ef3ffba
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: use accessor functions for qp values
v4l2 specifies different controls for the qp values of different codecs.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
35
5
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c +static inline int +allegro_channel_get_i_frame_qp(struct allegro_channel *channel) +{ + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_i_frame_qp); +} + +static inline int +allegro_channel_get_p_frame_qp(struct allegro_channel *channel) +{ + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_p_frame_qp); +} + +static inline int +allegro_channel_get_b_frame_qp(struct allegro_channel *channel) +{ + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_b_frame_qp); +} + +static inline int +allegro_channel_get_min_qp(struct allegro_channel *channel) +{ + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_min_qp); +} + +static inline int +allegro_channel_get_max_qp(struct allegro_channel *channel) +{ + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_max_qp); +} + - int i_frame_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_i_frame_qp); - int p_frame_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_p_frame_qp); - int b_frame_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_b_frame_qp); + int i_frame_qp = allegro_channel_get_i_frame_qp(channel); + int p_frame_qp = allegro_channel_get_p_frame_qp(channel); + int b_frame_qp = allegro_channel_get_b_frame_qp(channel); - param->min_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_min_qp); - param->max_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_max_qp); + param->min_qp = allegro_channel_get_min_qp(channel); + param->max_qp = allegro_channel_get_max_qp(channel);
TV tuners, webcams, video capturers
2b6e6e5b26cf556c576887d8d4e617d3020b6ed2
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: add helper to get entropy mode
the driver only supports cavlc for h.264, but hevc only uses cabac. as the driver has to explicitly tell the mcu to use cabac for hevc, add a helper function to get the entropy mode.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
9
0
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c +static u32 allegro_channel_get_entropy_mode(struct allegro_channel *channel) +{ +#define allegro_entropy_mode_cavlc 0 +#define allegro_entropy_mode_cabac 1 + + return allegro_entropy_mode_cavlc; +} + + param->entropy_mode = allegro_channel_get_entropy_mode(channel);
TV tuners, webcams, video capturers
655ef9f9e87568aff031391712669b74d1b362f1
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: rename codec specific functions
the maximum bitrate and the size of the cpb are dependent on the level. as the levels differ between the different codecs, the functions to get the maximum bitrate and cpb must be codec specific, too.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
7
7
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c -static unsigned int maximum_bitrate(enum v4l2_mpeg_video_h264_level level) +static unsigned int h264_maximum_bitrate(enum v4l2_mpeg_video_h264_level level) -static unsigned int maximum_cpb_size(enum v4l2_mpeg_video_h264_level level) +static unsigned int h264_maximum_cpb_size(enum v4l2_mpeg_video_h264_level level) - max = maximum_bitrate(v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level)); + max = h264_maximum_bitrate(v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level)); - bitrate_max = maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); - bitrate_def = maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); - cpb_size_max = maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); - cpb_size_def = maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); + bitrate_max = h264_maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); + bitrate_def = h264_maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); + cpb_size_max = h264_maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); + cpb_size_def = h264_maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1);
TV tuners, webcams, video capturers
4132dcbf5ccd8857d0be3ef80d2a8b70662fbc40
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: increase offset in capture buffer
the hevc non-vcl nal units require more space than the h.264 non-vcl nal units. therefore, the driver needs to reserve more space in front of the actual coded data that is written by the hardware codec.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
1
1
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c -#define encoder_stream_offset sz_64 +#define encoder_stream_offset sz_128
TV tuners, webcams, video capturers
be7f41f2f10c8605ba4b9a5515cf449006470b90
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: activate v4l2-ctrls only for current codec
these controls are specific to h.264 and shall only be activated, if the coded format is h.264.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['c']
1
16
0
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c + u32 codec = channel->codec; + v4l2_ctrl_activate(channel->mpeg_video_h264_profile, + codec == v4l2_pix_fmt_h264); + v4l2_ctrl_activate(channel->mpeg_video_h264_level, + codec == v4l2_pix_fmt_h264); + v4l2_ctrl_activate(channel->mpeg_video_h264_i_frame_qp, + codec == v4l2_pix_fmt_h264); + v4l2_ctrl_activate(channel->mpeg_video_h264_max_qp, + codec == v4l2_pix_fmt_h264); + v4l2_ctrl_activate(channel->mpeg_video_h264_min_qp, + codec == v4l2_pix_fmt_h264); + v4l2_ctrl_activate(channel->mpeg_video_h264_p_frame_qp, + codec == v4l2_pix_fmt_h264); + v4l2_ctrl_activate(channel->mpeg_video_h264_b_frame_qp, + codec == v4l2_pix_fmt_h264); +
TV tuners, webcams, video capturers
99b05ce74ceeb474ff4db37a0861b135063b7c7f
michael tretter
drivers
media
allegro-dvt, platform
media: allegro: add support for hevc encoding
the allegro codec supports hevc encoding. the messages to the mcu are the same for h.264 and hevc, but some options have to be changed. these are actually only a few options.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
add hevc support
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['allegro']
['h', 'c']
3
516
36
--- diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c +#include "nal-hevc.h" + bool enable_deblocking_filter_override; + bool enable_reordering; + + struct v4l2_ctrl *mpeg_video_hevc_profile; + struct v4l2_ctrl *mpeg_video_hevc_level; + struct v4l2_ctrl *mpeg_video_hevc_tier; + struct v4l2_ctrl *mpeg_video_hevc_i_frame_qp; + struct v4l2_ctrl *mpeg_video_hevc_max_qp; + struct v4l2_ctrl *mpeg_video_hevc_min_qp; + struct v4l2_ctrl *mpeg_video_hevc_p_frame_qp; + struct v4l2_ctrl *mpeg_video_hevc_b_frame_qp; + - return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_i_frame_qp); + if (channel->codec == v4l2_pix_fmt_hevc) + return v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_i_frame_qp); + else + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_i_frame_qp); - return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_p_frame_qp); + if (channel->codec == v4l2_pix_fmt_hevc) + return v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_p_frame_qp); + else + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_p_frame_qp); - return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_b_frame_qp); + if (channel->codec == v4l2_pix_fmt_hevc) + return v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_b_frame_qp); + else + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_b_frame_qp); - return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_min_qp); + if (channel->codec == v4l2_pix_fmt_hevc) + return v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_min_qp); + else + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_min_qp); - return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_max_qp); + if (channel->codec == v4l2_pix_fmt_hevc) + return v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_max_qp); + else + return v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_max_qp); +static enum v4l2_mpeg_video_hevc_level +select_minimum_hevc_level(unsigned int width, unsigned int height) +{ + unsigned int luma_picture_size = width * height; + enum v4l2_mpeg_video_hevc_level level; + + if (luma_picture_size <= 36864) + level = v4l2_mpeg_video_hevc_level_1; + else if (luma_picture_size <= 122880) + level = v4l2_mpeg_video_hevc_level_2; + else if (luma_picture_size <= 245760) + level = v4l2_mpeg_video_hevc_level_2_1; + else if (luma_picture_size <= 552960) + level = v4l2_mpeg_video_hevc_level_3; + else if (luma_picture_size <= 983040) + level = v4l2_mpeg_video_hevc_level_3_1; + else if (luma_picture_size <= 2228224) + level = v4l2_mpeg_video_hevc_level_4; + else if (luma_picture_size <= 8912896) + level = v4l2_mpeg_video_hevc_level_5; + else + level = v4l2_mpeg_video_hevc_level_6; + + return level; +} + +static unsigned int hevc_maximum_bitrate(enum v4l2_mpeg_video_hevc_level level) +{ + /* + * see rec. itu-t h.265 v5 (02/2018), a.4.2 profile-specific level + * limits for the video profiles. + */ + switch (level) { + case v4l2_mpeg_video_hevc_level_1: + return 128; + case v4l2_mpeg_video_hevc_level_2: + return 1500; + case v4l2_mpeg_video_hevc_level_2_1: + return 3000; + case v4l2_mpeg_video_hevc_level_3: + return 6000; + case v4l2_mpeg_video_hevc_level_3_1: + return 10000; + case v4l2_mpeg_video_hevc_level_4: + return 12000; + case v4l2_mpeg_video_hevc_level_4_1: + return 20000; + case v4l2_mpeg_video_hevc_level_5: + return 25000; + default: + case v4l2_mpeg_video_hevc_level_5_1: + return 40000; + } +} + +static unsigned int hevc_maximum_cpb_size(enum v4l2_mpeg_video_hevc_level level) +{ + switch (level) { + case v4l2_mpeg_video_hevc_level_1: + return 350; + case v4l2_mpeg_video_hevc_level_2: + return 1500; + case v4l2_mpeg_video_hevc_level_2_1: + return 3000; + case v4l2_mpeg_video_hevc_level_3: + return 6000; + case v4l2_mpeg_video_hevc_level_3_1: + return 10000; + case v4l2_mpeg_video_hevc_level_4: + return 12000; + case v4l2_mpeg_video_hevc_level_4_1: + return 20000; + case v4l2_mpeg_video_hevc_level_5: + return 25000; + default: + case v4l2_mpeg_video_hevc_level_5_1: + return 40000; + } +} + +static u8 hevc_profile_to_mcu_profile(enum v4l2_mpeg_video_hevc_profile profile) +{ + switch (profile) { + default: + case v4l2_mpeg_video_hevc_profile_main: + return 1; + case v4l2_mpeg_video_hevc_profile_main_10: + return 2; + case v4l2_mpeg_video_hevc_profile_main_still_picture: + return 3; + } +} + +static u16 hevc_level_to_mcu_level(enum v4l2_mpeg_video_hevc_level level) +{ + switch (level) { + case v4l2_mpeg_video_hevc_level_1: + return 10; + case v4l2_mpeg_video_hevc_level_2: + return 20; + case v4l2_mpeg_video_hevc_level_2_1: + return 21; + case v4l2_mpeg_video_hevc_level_3: + return 30; + case v4l2_mpeg_video_hevc_level_3_1: + return 31; + case v4l2_mpeg_video_hevc_level_4: + return 40; + case v4l2_mpeg_video_hevc_level_4_1: + return 41; + case v4l2_mpeg_video_hevc_level_5: + return 50; + default: + case v4l2_mpeg_video_hevc_level_5_1: + return 51; + } +} + +static u8 hevc_tier_to_mcu_tier(enum v4l2_mpeg_video_hevc_tier tier) +{ + switch (tier) { + default: + case v4l2_mpeg_video_hevc_tier_main: + return 0; + case v4l2_mpeg_video_hevc_tier_high: + return 1; + } +} + + /* hevc always uses cabac, but this has to be explicitly set */ + if (channel->codec == v4l2_pix_fmt_hevc) + return allegro_entropy_mode_cabac; + - enum v4l2_mpeg_video_h264_profile profile; - enum v4l2_mpeg_video_h264_level level; - profile = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_profile); - level = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level); - param->profile = v4l2_profile_to_mcu_profile(profile); - param->constraint_set_flags = bit(1); - param->level = v4l2_level_to_mcu_level(level); + if (channel->codec == v4l2_pix_fmt_h264) { + enum v4l2_mpeg_video_h264_profile profile; + enum v4l2_mpeg_video_h264_level level; + + profile = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_profile); + level = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level); + + param->profile = v4l2_profile_to_mcu_profile(profile); + param->constraint_set_flags = bit(1); + param->level = v4l2_level_to_mcu_level(level); + } else { + enum v4l2_mpeg_video_hevc_profile profile; + enum v4l2_mpeg_video_hevc_level level; + enum v4l2_mpeg_video_hevc_tier tier; + + profile = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_profile); + level = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_level); + tier = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_tier); + + param->profile = hevc_profile_to_mcu_profile(profile); + param->level = hevc_level_to_mcu_level(level); + param->tier = hevc_tier_to_mcu_tier(tier); + } + param->override_lf = channel->enable_deblocking_filter_override; + param->enable_reordering = channel->enable_reordering; +static ssize_t allegro_hevc_write_vps(struct allegro_channel *channel, + void *dest, size_t n) +{ + struct allegro_dev *dev = channel->dev; + struct nal_hevc_vps *vps; + struct nal_hevc_profile_tier_level *ptl; + ssize_t size; + unsigned int num_ref_frames = channel->num_ref_idx_l0; + s32 profile = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_profile); + s32 level = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_level); + s32 tier = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_tier); + + vps = kzalloc(sizeof(*vps), gfp_kernel); + if (!vps) + return -enomem; + + vps->base_layer_internal_flag = 1; + vps->base_layer_available_flag = 1; + vps->temporal_id_nesting_flag = 1; + + ptl = &vps->profile_tier_level; + ptl->general_profile_idc = nal_hevc_profile_from_v4l2(profile); + ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1; + ptl->general_tier_flag = nal_hevc_tier_from_v4l2(tier); + ptl->general_progressive_source_flag = 1; + ptl->general_frame_only_constraint_flag = 1; + ptl->general_level_idc = nal_hevc_level_from_v4l2(level); + + vps->sub_layer_ordering_info_present_flag = 0; + vps->max_dec_pic_buffering_minus1[0] = num_ref_frames; + vps->max_num_reorder_pics[0] = num_ref_frames; + + size = nal_hevc_write_vps(&dev->plat_dev->dev, dest, n, vps); + + kfree(vps); + + return size; +} + +static ssize_t allegro_hevc_write_sps(struct allegro_channel *channel, + void *dest, size_t n) +{ + struct allegro_dev *dev = channel->dev; + struct nal_hevc_sps *sps; + struct nal_hevc_profile_tier_level *ptl; + ssize_t size; + unsigned int num_ref_frames = channel->num_ref_idx_l0; + s32 profile = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_profile); + s32 level = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_level); + s32 tier = v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_tier); + + sps = kzalloc(sizeof(*sps), gfp_kernel); + if (!sps) + return -enomem; + + sps->temporal_id_nesting_flag = 1; + + ptl = &sps->profile_tier_level; + ptl->general_profile_idc = nal_hevc_profile_from_v4l2(profile); + ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1; + ptl->general_tier_flag = nal_hevc_tier_from_v4l2(tier); + ptl->general_progressive_source_flag = 1; + ptl->general_frame_only_constraint_flag = 1; + ptl->general_level_idc = nal_hevc_level_from_v4l2(level); + + sps->seq_parameter_set_id = 0; + sps->chroma_format_idc = 1; /* only 4:2:0 sampling supported */ + sps->pic_width_in_luma_samples = round_up(channel->width, 8); + sps->pic_height_in_luma_samples = round_up(channel->height, 8); + sps->conf_win_right_offset = + sps->pic_width_in_luma_samples - channel->width; + sps->conf_win_bottom_offset = + sps->pic_height_in_luma_samples - channel->height; + sps->conformance_window_flag = + sps->conf_win_right_offset || sps->conf_win_bottom_offset; + + sps->log2_max_pic_order_cnt_lsb_minus4 = log2_max_pic_order_cnt - 4; + + sps->sub_layer_ordering_info_present_flag = 1; + sps->max_dec_pic_buffering_minus1[0] = num_ref_frames; + sps->max_num_reorder_pics[0] = num_ref_frames; + + sps->log2_min_luma_coding_block_size_minus3 = + channel->min_cu_size - 3; + sps->log2_diff_max_min_luma_coding_block_size = + channel->max_cu_size - channel->min_cu_size; + sps->log2_min_luma_transform_block_size_minus2 = + channel->min_tu_size - 2; + sps->log2_diff_max_min_luma_transform_block_size = + channel->max_tu_size - channel->min_tu_size; + sps->max_transform_hierarchy_depth_intra = + channel->max_transfo_depth_intra; + sps->max_transform_hierarchy_depth_inter = + channel->max_transfo_depth_inter; + + sps->sps_temporal_mvp_enabled_flag = channel->temporal_mvp_enable; + sps->strong_intra_smoothing_enabled_flag = channel->max_cu_size > 4; + + size = nal_hevc_write_sps(&dev->plat_dev->dev, dest, n, sps); + + kfree(sps); + + return size; +} + +static ssize_t allegro_hevc_write_pps(struct allegro_channel *channel, + struct mcu_msg_encode_frame_response *msg, + void *dest, size_t n) +{ + struct allegro_dev *dev = channel->dev; + struct nal_hevc_pps *pps; + ssize_t size; + int i; + + pps = kzalloc(sizeof(*pps), gfp_kernel); + if (!pps) + return -enomem; + + pps->pps_pic_parameter_set_id = 0; + pps->pps_seq_parameter_set_id = 0; + + if (msg->num_column > 1 || msg->num_row > 1) { + pps->tiles_enabled_flag = 1; + pps->num_tile_columns_minus1 = msg->num_column - 1; + pps->num_tile_rows_minus1 = msg->num_row - 1; + + for (i = 0; i < msg->num_column; i++) + pps->column_width_minus1[i] = msg->tile_width[i] - 1; + + for (i = 0; i < msg->num_row; i++) + pps->row_height_minus1[i] = msg->tile_height[i] - 1; + } + + pps->loop_filter_across_tiles_enabled_flag = + channel->enable_loop_filter_across_tiles; + pps->pps_loop_filter_across_slices_enabled_flag = + channel->enable_loop_filter_across_slices; + pps->deblocking_filter_control_present_flag = 1; + pps->deblocking_filter_override_enabled_flag = + channel->enable_deblocking_filter_override; + pps->pps_beta_offset_div2 = beta_offset_div_2; + pps->pps_tc_offset_div2 = tc_offset_div_2; + + pps->lists_modification_present_flag = channel->enable_reordering; + + size = nal_hevc_write_pps(&dev->plat_dev->dev, dest, n, pps); + + kfree(pps); + + return size; +} + + + if (channel->codec == v4l2_pix_fmt_hevc && msg->is_idr) { + len = allegro_hevc_write_vps(channel, curr, free); + if (len < 0) { + v4l2_err(&dev->v4l2_dev, + "not enough space for video parameter set: %zd left ", + free); + goto err; + } + curr += len; + free -= len; + v4l2_dbg(1, debug, &dev->v4l2_dev, + "channel %d: wrote %zd byte vps nal unit ", + channel->mcu_channel_id, len); + } + - len = allegro_h264_write_sps(channel, curr, free); + if (channel->codec == v4l2_pix_fmt_h264) + len = allegro_h264_write_sps(channel, curr, free); + else + len = allegro_hevc_write_sps(channel, curr, free); - len = allegro_h264_write_pps(channel, curr, free); + if (channel->codec == v4l2_pix_fmt_h264) + len = allegro_h264_write_pps(channel, curr, free); + else + len = allegro_hevc_write_pps(channel, msg, curr, free); - len = nal_h264_write_filler(&dev->plat_dev->dev, curr, free); + if (channel->codec == v4l2_pix_fmt_h264) + len = nal_h264_write_filler(&dev->plat_dev->dev, curr, free); + else + len = nal_hevc_write_filler(&dev->plat_dev->dev, curr, free); + + v4l2_ctrl_grab(channel->mpeg_video_hevc_profile, false); + v4l2_ctrl_grab(channel->mpeg_video_hevc_level, false); + v4l2_ctrl_grab(channel->mpeg_video_hevc_tier, false); + v4l2_ctrl_grab(channel->mpeg_video_hevc_i_frame_qp, false); + v4l2_ctrl_grab(channel->mpeg_video_hevc_max_qp, false); + v4l2_ctrl_grab(channel->mpeg_video_hevc_min_qp, false); + v4l2_ctrl_grab(channel->mpeg_video_hevc_p_frame_qp, false); + v4l2_ctrl_grab(channel->mpeg_video_hevc_b_frame_qp, false); + + + v4l2_ctrl_grab(channel->mpeg_video_hevc_profile, true); + v4l2_ctrl_grab(channel->mpeg_video_hevc_level, true); + v4l2_ctrl_grab(channel->mpeg_video_hevc_tier, true); + v4l2_ctrl_grab(channel->mpeg_video_hevc_i_frame_qp, true); + v4l2_ctrl_grab(channel->mpeg_video_hevc_max_qp, true); + v4l2_ctrl_grab(channel->mpeg_video_hevc_min_qp, true); + v4l2_ctrl_grab(channel->mpeg_video_hevc_p_frame_qp, true); + v4l2_ctrl_grab(channel->mpeg_video_hevc_b_frame_qp, true); + - ctrl = channel->mpeg_video_h264_level; - min = select_minimum_h264_level(channel->width, channel->height); + if (codec == v4l2_pix_fmt_h264) { + ctrl = channel->mpeg_video_h264_level; + min = select_minimum_h264_level(channel->width, channel->height); + } else { + ctrl = channel->mpeg_video_hevc_level; + min = select_minimum_hevc_level(channel->width, channel->height); + } - max = h264_maximum_bitrate(v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level)); + if (codec == v4l2_pix_fmt_h264) + max = h264_maximum_bitrate(v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_level)); + else + max = hevc_maximum_bitrate(v4l2_ctrl_g_ctrl(channel->mpeg_video_hevc_level)); - channel->log2_max_frame_num = log2_max_frame_num; + v4l2_ctrl_activate(channel->mpeg_video_hevc_profile, + codec == v4l2_pix_fmt_hevc); + v4l2_ctrl_activate(channel->mpeg_video_hevc_level, + codec == v4l2_pix_fmt_hevc); + v4l2_ctrl_activate(channel->mpeg_video_hevc_tier, + codec == v4l2_pix_fmt_hevc); + v4l2_ctrl_activate(channel->mpeg_video_hevc_i_frame_qp, + codec == v4l2_pix_fmt_hevc); + v4l2_ctrl_activate(channel->mpeg_video_hevc_max_qp, + codec == v4l2_pix_fmt_hevc); + v4l2_ctrl_activate(channel->mpeg_video_hevc_min_qp, + codec == v4l2_pix_fmt_hevc); + v4l2_ctrl_activate(channel->mpeg_video_hevc_p_frame_qp, + codec == v4l2_pix_fmt_hevc); + v4l2_ctrl_activate(channel->mpeg_video_hevc_b_frame_qp, + codec == v4l2_pix_fmt_hevc); + + if (codec == v4l2_pix_fmt_h264) + channel->log2_max_frame_num = log2_max_frame_num; - - channel->dbf_ovr_en = true; + channel->dbf_ovr_en = (codec == v4l2_pix_fmt_h264); + channel->enable_deblocking_filter_override = (codec == v4l2_pix_fmt_hevc); + channel->enable_reordering = (codec == v4l2_pix_fmt_hevc); - channel->b_hrz_me_range = 8; - channel->b_vrt_me_range = 8; - channel->p_hrz_me_range = 16; - channel->p_vrt_me_range = 16; - channel->max_cu_size = ilog2(16); - channel->min_cu_size = ilog2(8); - channel->max_tu_size = ilog2(4); - channel->min_tu_size = ilog2(4); + if (codec == v4l2_pix_fmt_h264) { + channel->b_hrz_me_range = 8; + channel->b_vrt_me_range = 8; + channel->p_hrz_me_range = 16; + channel->p_vrt_me_range = 16; + channel->max_cu_size = ilog2(16); + channel->min_cu_size = ilog2(8); + channel->max_tu_size = ilog2(4); + channel->min_tu_size = ilog2(4); + } else { + channel->b_hrz_me_range = 16; + channel->b_vrt_me_range = 16; + channel->p_hrz_me_range = 32; + channel->p_vrt_me_range = 32; + channel->max_cu_size = ilog2(32); + channel->min_cu_size = ilog2(8); + channel->max_tu_size = ilog2(32); + channel->min_tu_size = ilog2(4); + } + + channel->mpeg_video_hevc_profile = + v4l2_ctrl_new_std_menu(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_profile, + v4l2_mpeg_video_hevc_profile_main, 0x0, + v4l2_mpeg_video_hevc_profile_main); + channel->mpeg_video_hevc_level = + v4l2_ctrl_new_std_menu(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_level, + v4l2_mpeg_video_hevc_level_5_1, 0x0, + v4l2_mpeg_video_hevc_level_5_1); + channel->mpeg_video_hevc_tier = + v4l2_ctrl_new_std_menu(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_tier, + v4l2_mpeg_video_hevc_tier_high, 0x0, + v4l2_mpeg_video_hevc_tier_main); + channel->mpeg_video_hevc_i_frame_qp = + v4l2_ctrl_new_std(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_i_frame_qp, + 0, 51, 1, 30); + channel->mpeg_video_hevc_max_qp = + v4l2_ctrl_new_std(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_max_qp, + 0, 51, 1, 51); + channel->mpeg_video_hevc_min_qp = + v4l2_ctrl_new_std(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_min_qp, + 0, 51, 1, 0); + channel->mpeg_video_hevc_p_frame_qp = + v4l2_ctrl_new_std(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_p_frame_qp, + 0, 51, 1, 30); + channel->mpeg_video_hevc_b_frame_qp = + v4l2_ctrl_new_std(handler, + &allegro_ctrl_ops, + v4l2_cid_mpeg_video_hevc_b_frame_qp, + 0, 51, 1, 30); + - bitrate_max = h264_maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); - bitrate_def = h264_maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); - cpb_size_max = h264_maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); - cpb_size_def = h264_maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); + if (channel->codec == v4l2_pix_fmt_h264) { + bitrate_max = h264_maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); + bitrate_def = h264_maximum_bitrate(v4l2_mpeg_video_h264_level_5_1); + cpb_size_max = h264_maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); + cpb_size_def = h264_maximum_cpb_size(v4l2_mpeg_video_h264_level_5_1); + } else { + bitrate_max = hevc_maximum_bitrate(v4l2_mpeg_video_hevc_level_5_1); + bitrate_def = hevc_maximum_bitrate(v4l2_mpeg_video_hevc_level_5_1); + cpb_size_max = hevc_maximum_cpb_size(v4l2_mpeg_video_hevc_level_5_1); + cpb_size_def = hevc_maximum_cpb_size(v4l2_mpeg_video_hevc_level_5_1); + } - if (f->index >= 1) + if (f->index >= 2) - f->pixelformat = v4l2_pix_fmt_h264; + if (f->index == 0) + f->pixelformat = v4l2_pix_fmt_h264; + if (f->index == 1) + f->pixelformat = v4l2_pix_fmt_hevc; - f->fmt.pix.pixelformat = v4l2_pix_fmt_h264; + if (f->fmt.pix.pixelformat != v4l2_pix_fmt_hevc && + f->fmt.pix.pixelformat != v4l2_pix_fmt_h264) + f->fmt.pix.pixelformat = v4l2_pix_fmt_h264; + + case v4l2_pix_fmt_hevc: diff --git a/drivers/media/platform/allegro-dvt/allegro-mail.c b/drivers/media/platform/allegro-dvt/allegro-mail.c --- a/drivers/media/platform/allegro-dvt/allegro-mail.c +++ b/drivers/media/platform/allegro-dvt/allegro-mail.c + case v4l2_pix_fmt_hevc: + return 2; + case v4l2_pix_fmt_hevc: + return 1; + val |= param->enable_reordering ? bit(0) : 0; + val |= param->override_lf ? bit(12) : 0; diff --git a/drivers/media/platform/allegro-dvt/allegro-mail.h b/drivers/media/platform/allegro-dvt/allegro-mail.h --- a/drivers/media/platform/allegro-dvt/allegro-mail.h +++ b/drivers/media/platform/allegro-dvt/allegro-mail.h + u32 override_lf;
TV tuners, webcams, video capturers
b08797d1b2ec25165768c841a2ac484fecd72be1
michael tretter
drivers
media
allegro-dvt, platform
media: dt-bindings: media: i2c: rename ov5647.yaml
rename 'ov5647.yaml' as 'ovti,ov5647.yaml' and update the maintainers file entry accordingly.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['yaml', 'maintainers']
2
1
1
--- diff --git a/documentation/devicetree/bindings/media/i2c/ov5647.yaml b/documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers -f: documentation/devicetree/bindings/media/i2c/ov5647.yaml +f: documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml
TV tuners, webcams, video capturers
1b5071af824039cb71592d5b2a60773ee1ee94be
jacopo mondi
documentation
devicetree
bindings, i2c, media
media: ov5647: add support for pwdn gpio.
add support for an optional gpio connected to pwdn on the sensor. this allows the use of hardware standby mode where internal device clock and circuit activities are halted.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
32
0
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +#include <linux/gpio/consumer.h> +/* + * from the datasheet, "20ms after pwdn goes low or 20ms after resetb goes + * high if reset is inserted after pwdn goes high, host can access sensor's + * sccb to initialize sensor." + */ +#define pwdn_active_delay_ms 20 + + struct gpio_desc *pwdn; + if (ov5647->pwdn) { + gpiod_set_value_cansleep(ov5647->pwdn, 0); + msleep(pwdn_active_delay_ms); + } + + + gpiod_set_value_cansleep(ov5647->pwdn, 1); + /* request the power down gpio asserted */ + sensor->pwdn = devm_gpiod_get_optional(&client->dev, "pwdn", + gpiod_out_high); + if (is_err(sensor->pwdn)) { + dev_err(dev, "failed to get 'pwdn' gpio "); + return -einval; + } + + if (sensor->pwdn) { + gpiod_set_value_cansleep(sensor->pwdn, 0); + msleep(pwdn_active_delay_ms); + } + + + gpiod_set_value_cansleep(sensor->pwdn, 1); +
TV tuners, webcams, video capturers
b050791d287afcaa1114321dd409c77ca90da880
dave stevenson
drivers
media
i2c
media: ov5647: add support for non-continuous clock mode
add support for optional non-continuous clock mode to the ov5647 sensor driver.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
20
4
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +#define mipi_ctrl00_line_sync_enable bit(4) + bool clock_ncont; + struct ov5647 *ov5647 = to_state(sd); + u8 val = mipi_ctrl00_bus_idle; - ret = ov5647_write(sd, ov5647_reg_mipi_ctrl00, mipi_ctrl00_bus_idle); + if (ov5647->clock_ncont) + val |= mipi_ctrl00_clock_lane_gate | + mipi_ctrl00_line_sync_enable; + + ret = ov5647_write(sd, ov5647_reg_mipi_ctrl00, val); -static int ov5647_parse_dt(struct device_node *np) +static int ov5647_parse_dt(struct ov5647 *sensor, struct device_node *np) - struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 }; + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = v4l2_mbus_csi2_dphy, + }; + if (ret) + goto out; + sensor->clock_ncont = bus_cfg.bus.mipi_csi2.flags & + v4l2_mbus_csi2_noncontinuous_clock; + +out: - ret = ov5647_parse_dt(np); + ret = ov5647_parse_dt(sensor, np);
TV tuners, webcams, video capturers
dea4fcfe77d25f8069ef6a48dab9b732c4074ee2
dave stevenson
drivers
media
i2c
media: ov5647: add set_fmt and get_fmt calls.
there's no way to query the subdevice for the supported resolutions. add set_fmt and get_fmt implementations. since there's only one format supported set_fmt does nothing and get returns single format.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
19
0
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +static int ov5647_set_get_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *format) +{ + struct v4l2_mbus_framefmt *fmt = &format->format; + + /* only one format is supported, so return that */ + memset(fmt, 0, sizeof(*fmt)); + fmt->code = media_bus_fmt_sbggr8_1x8; + fmt->colorspace = v4l2_colorspace_srgb; + fmt->field = v4l2_field_none; + fmt->width = 640; + fmt->height = 480; + + return 0; +} + + .set_fmt = ov5647_set_get_fmt, + .get_fmt = ov5647_set_get_fmt,
TV tuners, webcams, video capturers
0f87233a473de6cc22c4785d53aea41c1939f0c9
dave stevenson
drivers
media
i2c
media: ov5647: fix format initialization
the driver currently support a single format. fix its initialization to use the only supported resolution.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
2
3
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c - - format->width = ov5647_window_width_def; - format->height = ov5647_window_height_def; + format->width = 640; + format->height = 480;
TV tuners, webcams, video capturers
7a4826309722ad86679a61e9a3bde80c1ef3c8d5
jacopo mondi
drivers
media
i2c
media: ov5647: fix style issues
the driver has some obvious style issues which are worth fixing before expanding the driver capabilities.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
47
55
- variable declaration order - function parameters alignment - multi-line comments and spurious line breaks - use lowercase for hexadecimal values - > 80 cols lines --- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c -#define sensor_name "ov5647" - -#define ov5647_reg_chipid_h 0x300a -#define ov5647_reg_chipid_l 0x300b -#define ov5640_reg_pad_out 0x300d +#define ov5647_reg_chipid_h 0x300a +#define ov5647_reg_chipid_l 0x300b +#define ov5640_reg_pad_out 0x300d - {0x380b, 0xe0}, + {0x380b, 0xe0}, - int ret; + int ret; - int ret; + int ret; - struct regval_list *regs, int array_size) + struct regval_list *regs, int array_size) - return ov5647_write(sd, ov5647_reg_mipi_ctrl14, channel_id | (channel << 6)); + + return ov5647_write(sd, ov5647_reg_mipi_ctrl14, + channel_id | (channel << 6)); - ret = ov5647_write(sd, ov5647_reg_mipi_ctrl00, mipi_ctrl00_clock_lane_gate - | mipi_ctrl00_bus_idle | mipi_ctrl00_clock_lane_disable); + ret = ov5647_write(sd, ov5647_reg_mipi_ctrl00, + mipi_ctrl00_clock_lane_gate | mipi_ctrl00_bus_idle | + mipi_ctrl00_clock_lane_disable); - int ret; - u8 resetval, rdval; + u8 resetval, rdval; + int ret; - array_size(ov5647_640x480)); + array_size(ov5647_640x480)); - /* - * stream off to make the clock lane into lp-11 state. - */ + /* stream off to make the clock lane into lp-11 state. */ - int ret = 0; - struct ov5647 *ov5647 = to_state(sd); + struct ov5647 *ov5647 = to_state(sd); + int ret = 0; - array_size(sensor_oe_enable_regs)); + array_size(sensor_oe_enable_regs)); - array_size(sensor_oe_disable_regs)); - + array_size(sensor_oe_disable_regs)); - - - struct v4l2_dbg_register *reg) + struct v4l2_dbg_register *reg) - u8 val; + u8 val; - const struct v4l2_dbg_register *reg) + const struct v4l2_dbg_register *reg) -/* - * subdev core operations registration - */ +/* subdev core operations registration */ - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_mbus_code_enum *code) - /* only one format is supported, so return that */ + /* only one format is supported, so return that. */ + struct i2c_client *client = v4l2_get_subdevdata(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct v4l2_rect *crop = - v4l2_subdev_get_try_crop(sd, fh->pad, 0); + struct v4l2_rect *crop = v4l2_subdev_get_try_crop(sd, fh->pad, 0); - + + struct device_node *np = client->dev.of_node; - int ret; - struct device_node *np = client->dev.of_node; + int ret; - /* get system clock (xclk) */ - /* request the power down gpio asserted */ - sensor->pwdn = devm_gpiod_get_optional(&client->dev, "pwdn", - gpiod_out_high); + /* request the power down gpio asserted. */ + sensor->pwdn = devm_gpiod_get_optional(dev, "pwdn", gpiod_out_high); - sensor->sd.internal_ops = &ov5647_subdev_internal_ops; - sensor->sd.flags |= v4l2_subdev_fl_has_devnode; + sd->internal_ops = &ov5647_subdev_internal_ops; + sd->flags |= v4l2_subdev_fl_has_devnode; - goto mutex_remove; + goto mutex_destroy; - - - goto error; + goto entity_cleanup; - goto error; + goto entity_cleanup; + -error: + +entity_cleanup: -mutex_remove: +mutex_destroy: + - { } + { /* sentinel */ } - .name = sensor_name, + .name = "ov5647",
TV tuners, webcams, video capturers
c9a05cece64c609b68777d6e536f695ac1c8f8d3
jacopo mondi
drivers
media
i2c
media: ov5647: replace license with spdx identifier
replace the boilerplate license text with the spdx identifier.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
1
9
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +// spdx-license-identifier: gpl-2.0 - * - * this program is free software; you can redistribute it and/or - * modify it under the terms of the gnu general public license as - * published by the free software foundation version 2. - * - * this program is distributed .as is. without any warranty of any - * kind, whether express or implied; without even the implied warranty - * of merchantability or fitness for a particular purpose. see the - * gnu general public license for more details.
TV tuners, webcams, video capturers
24169a5aee250d53c5d588b6df34b7940c3f875a
jacopo mondi
drivers
media
i2c
media: ov5647: fix return value from read/write
the ov5647_read()/ov5647_write() return in case of success the number of bytes read or written respectively. this requires callers to check if the return value is less than zero to detect an error. unfortunately, in several places, callers directly return the result of a read/write call, causing issues when the returned valued is checked to be different from zero to detect an error.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
8
4
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c - if (ret < 0) + if (ret < 0) { + return ret; + } - return ret; + return 0; - if (ret < 0) + if (ret < 0) { + return ret; + } - return ret; + return 0;
TV tuners, webcams, video capturers
2b18cbcf53f4b1f24f758cfee328fb27432c4e19
jacopo mondi
drivers
media
i2c
media: ov5647: program mode at s_stream(1) time
rename __sensor_init() function to ov5647_set_mode() as the function is a regular one and the double underscores prefix shall be removed, and then move it to program the mode at s_stream(1) time, not at sensor power up.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
44
37
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +static int ov5647_set_mode(struct v4l2_subdev *sd) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + u8 resetval, rdval; + int ret; + + ret = ov5647_read(sd, ov5647_sw_standby, &rdval); + if (ret < 0) + return ret; + + ret = ov5647_write_array(sd, ov5647_640x480, + array_size(ov5647_640x480)); + if (ret < 0) { + dev_err(&client->dev, "write sensor default regs error "); + return ret; + } + + ret = ov5647_set_virtual_channel(sd, 0); + if (ret < 0) + return ret; + + ret = ov5647_read(sd, ov5647_sw_standby, &resetval); + if (ret < 0) + return ret; + + if (!(resetval & 0x01)) { + dev_err(&client->dev, "device was in sw standby"); + ret = ov5647_write(sd, ov5647_sw_standby, 0x01); + if (ret < 0) + return ret; + } + + return 0; +} + + struct i2c_client *client = v4l2_get_subdevdata(sd); + ret = ov5647_set_mode(sd); + if (ret) { + dev_err(&client->dev, "failed to program sensor mode: %d ", ret); + return ret; + } + -static int __sensor_init(struct v4l2_subdev *sd) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - u8 resetval, rdval; - int ret; - - ret = ov5647_read(sd, ov5647_sw_standby, &rdval); - if (ret < 0) - return ret; - - ret = ov5647_write_array(sd, ov5647_640x480, - array_size(ov5647_640x480)); - if (ret < 0) { - dev_err(&client->dev, "write sensor default regs error "); - return ret; - } - - ret = ov5647_set_virtual_channel(sd, 0); - if (ret < 0) - return ret; - - ret = ov5647_read(sd, ov5647_sw_standby, &resetval); - if (ret < 0) - return ret; - - if (!(resetval & 0x01)) { - dev_err(&client->dev, "device was in sw standby"); - ret = ov5647_write(sd, ov5647_sw_standby, 0x01); - if (ret < 0) - return ret; - } - - /* stream off to make the clock lane into lp-11 state. */ - return ov5647_stream_off(sd); -} - - ret = __sensor_init(sd); + /* stream off to coax lanes into lp-11 state. */ + ret = ov5647_stream_off(sd);
TV tuners, webcams, video capturers
f7a70f9a43a641380c8df40f97561b671ed79926
jacopo mondi
drivers
media
i2c
media: ov5647: implement enum_frame_size()
implement the .enum_frame_size subdev pad operation.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
22
3
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +static int ov5647_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) +{ + if (fse->index) + return -einval; + + if (fse->code != media_bus_fmt_sbggr8_1x8) + return -einval; + + fse->min_width = 640; + fse->max_width = 640; + fse->min_height = 480; + fse->max_height = 480; + + return 0; +} + - .enum_mbus_code = ov5647_enum_mbus_code, - .set_fmt = ov5647_set_get_fmt, - .get_fmt = ov5647_set_get_fmt, + .enum_mbus_code = ov5647_enum_mbus_code, + .enum_frame_size = ov5647_enum_frame_size, + .set_fmt = ov5647_set_get_fmt, + .get_fmt = ov5647_set_get_fmt,
TV tuners, webcams, video capturers
464090c0af3de6f3fe3a6329f524eadb6a8d9744
jacopo mondi
drivers
media
i2c
media: ov5647: protect s_stream() with mutex
use the driver mutex to protect s_stream() operations. this will become more relevant once the sensor will support more formats and set_format() could be issue concurrently to s_stream().
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
9
2
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c + struct ov5647 *sensor = to_state(sd); + int ret; + + mutex_lock(&sensor->lock); - return ov5647_stream_on(sd); + ret = ov5647_stream_on(sd); - return ov5647_stream_off(sd); + ret = ov5647_stream_off(sd); + mutex_unlock(&sensor->lock); + + return ret;
TV tuners, webcams, video capturers
ab614f27569ffab2441cc8f45fc24b6467aafb3c
jacopo mondi
drivers
media
i2c
media: ov5647: support gain, exposure and awb controls
add controls to support awb, aec and agc. also add control support to set exposure (in lines) and analogue gain (as a register code).
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
170
2
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +#include <media/v4l2-ctrls.h> +#define ov5647_reg_exp_hi 0x3500 +#define ov5647_reg_exp_mid 0x3501 +#define ov5647_reg_exp_lo 0x3502 +#define ov5647_reg_aec_agc 0x3503 +#define ov5647_reg_gain_hi 0x350a +#define ov5647_reg_gain_lo 0x350b +#define ov5647_reg_awb 0x5001 + struct v4l2_ctrl_handler ctrls; - {0x5001, 0x01}, + /* apply customized values from user when stream starts. */ + ret = __v4l2_ctrl_handler_setup(sd->ctrl_handler); + if (ret) + return ret; + +static int ov5647_s_auto_white_balance(struct v4l2_subdev *sd, u32 val) +{ + return ov5647_write(sd, ov5647_reg_awb, val ? 1 : 0); +} + +static int ov5647_s_autogain(struct v4l2_subdev *sd, u32 val) +{ + int ret; + u8 reg; + + /* non-zero turns on agc by clearing bit 1.*/ + ret = ov5647_read(sd, ov5647_reg_aec_agc, &reg); + if (ret) + return ret; + + return ov5647_write(sd, ov5647_reg_aec_agc, val ? reg & ~bit(1) + : reg | bit(1)); +} + +static int ov5647_s_exposure_auto(struct v4l2_subdev *sd, u32 val) +{ + int ret; + u8 reg; + + /* + * everything except v4l2_exposure_manual turns on aec by + * clearing bit 0. + */ + ret = ov5647_read(sd, ov5647_reg_aec_agc, &reg); + if (ret) + return ret; + + return ov5647_write(sd, ov5647_reg_aec_agc, + val == v4l2_exposure_manual ? reg | bit(0) + : reg & ~bit(0)); +} + +static int ov5647_s_analogue_gain(struct v4l2_subdev *sd, u32 val) +{ + int ret; + + /* 10 bits of gain, 2 in the high register. */ + ret = ov5647_write(sd, ov5647_reg_gain_hi, (val >> 8) & 3); + if (ret) + return ret; + + return ov5647_write(sd, ov5647_reg_gain_lo, val & 0xff); +} + +static int ov5647_s_exposure(struct v4l2_subdev *sd, u32 val) +{ + int ret; + + /* + * sensor has 20 bits, but the bottom 4 bits are fractions of a line + * which we leave as zero (and don't receive in "val"). + */ + ret = ov5647_write(sd, ov5647_reg_exp_hi, (val >> 12) & 0xf); + if (ret) + return ret; + + ret = ov5647_write(sd, ov5647_reg_exp_mid, (val >> 4) & 0xff); + if (ret) + return ret; + + return ov5647_write(sd, ov5647_reg_exp_lo, (val & 0xf) << 4); +} + +static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct ov5647 *sensor = container_of(ctrl->handler, + struct ov5647, ctrls); + struct v4l2_subdev *sd = &sensor->sd; + struct i2c_client *client = v4l2_get_subdevdata(sd); + + /* v4l2_ctrl_lock() locks our own mutex */ + + /* + * if the device is not powered up by the host driver do + * not apply any controls to h/w at this time. instead + * the controls will be restored at s_stream(1) time. + */ + if (!sensor->power_count) + return 0; + + switch (ctrl->id) { + case v4l2_cid_auto_white_balance: + return ov5647_s_auto_white_balance(sd, ctrl->val); + case v4l2_cid_autogain: + return ov5647_s_autogain(sd, ctrl->val); + case v4l2_cid_exposure_auto: + return ov5647_s_exposure_auto(sd, ctrl->val); + case v4l2_cid_analogue_gain: + return ov5647_s_analogue_gain(sd, ctrl->val); + case v4l2_cid_exposure: + return ov5647_s_exposure(sd, ctrl->val); + default: + dev_info(&client->dev, + "control (id:0x%x, val:0x%x) not supported ", + ctrl->id, ctrl->val); + return -einval; + } + + return 0; +} + +static const struct v4l2_ctrl_ops ov5647_ctrl_ops = { + .s_ctrl = ov5647_s_ctrl, +}; + +static int ov5647_init_controls(struct ov5647 *sensor) +{ + struct i2c_client *client = v4l2_get_subdevdata(&sensor->sd); + + v4l2_ctrl_handler_init(&sensor->ctrls, 5); + + v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops, + v4l2_cid_autogain, 0, 1, 1, 0); + + v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops, + v4l2_cid_auto_white_balance, 0, 1, 1, 0); + + v4l2_ctrl_new_std_menu(&sensor->ctrls, &ov5647_ctrl_ops, + v4l2_cid_exposure_auto, v4l2_exposure_manual, + 0, v4l2_exposure_manual); + + /* min: 4 lines; max: 0xffff lines; default: 1000 lines. */ + v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops, + v4l2_cid_exposure, 4, 65535, 1, 1000); + + /* min: 16 = 1.0x; max (10 bits); default: 32 = 2.0x. */ + v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops, + v4l2_cid_analogue_gain, 16, 1023, 1, 32); + + if (sensor->ctrls.error) { + dev_err(&client->dev, + "%s controls initialization failed (%d) ", + __func__, sensor->ctrls.error); + v4l2_ctrl_handler_free(&sensor->ctrls); + + return sensor->ctrls.error; + } + + sensor->sd.ctrl_handler = &sensor->ctrls; + + return 0; +} + + ret = ov5647_init_controls(sensor); + if (ret) + goto mutex_destroy; + - goto mutex_destroy; + goto ctrl_handler_free; +ctrl_handler_free: + v4l2_ctrl_handler_free(&sensor->ctrls); + v4l2_ctrl_handler_free(&ov5647->ctrls);
TV tuners, webcams, video capturers
4974c2f19fd810ec9a4e534bfc69e176256b7a03
david plowman
drivers
media
i2c
media: ov5647: rationalize driver structure name
the driver structure name is referred to with different names ('ov5647', 'state', 'sensor') in different functions in the driver.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
23
23
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c -static inline struct ov5647 *to_state(struct v4l2_subdev *sd) +static inline struct ov5647 *to_sensor(struct v4l2_subdev *sd) - struct ov5647 *ov5647 = to_state(sd); + struct ov5647 *sensor = to_sensor(sd); - if (ov5647->clock_ncont) + if (sensor->clock_ncont) - struct ov5647 *ov5647 = to_state(sd); + struct ov5647 *sensor = to_sensor(sd); - mutex_lock(&ov5647->lock); + mutex_lock(&sensor->lock); - if (on && !ov5647->power_count) { + if (on && !sensor->power_count) { - if (ov5647->pwdn) { - gpiod_set_value_cansleep(ov5647->pwdn, 0); + if (sensor->pwdn) { + gpiod_set_value_cansleep(sensor->pwdn, 0); - ret = clk_prepare_enable(ov5647->xclk); + ret = clk_prepare_enable(sensor->xclk); - clk_disable_unprepare(ov5647->xclk); + clk_disable_unprepare(sensor->xclk); - clk_disable_unprepare(ov5647->xclk); + clk_disable_unprepare(sensor->xclk); - } else if (!on && ov5647->power_count == 1) { + } else if (!on && sensor->power_count == 1) { - clk_disable_unprepare(ov5647->xclk); - gpiod_set_value_cansleep(ov5647->pwdn, 1); + clk_disable_unprepare(sensor->xclk); + gpiod_set_value_cansleep(sensor->pwdn, 1); - ov5647->power_count += on ? 1 : -1; - warn_on(ov5647->power_count < 0); + sensor->power_count += on ? 1 : -1; + warn_on(sensor->power_count < 0); - mutex_unlock(&ov5647->lock); + mutex_unlock(&sensor->lock); - struct ov5647 *sensor = to_state(sd); + struct ov5647 *sensor = to_sensor(sd); - struct ov5647 *ov5647 = to_state(sd); + struct ov5647 *sensor = to_sensor(sd); - v4l2_async_unregister_subdev(&ov5647->sd); - media_entity_cleanup(&ov5647->sd.entity); - v4l2_ctrl_handler_free(&ov5647->ctrls); + v4l2_async_unregister_subdev(&sensor->sd); + media_entity_cleanup(&sensor->sd.entity); + v4l2_ctrl_handler_free(&sensor->ctrls); - mutex_destroy(&ov5647->lock); + mutex_destroy(&sensor->lock);
TV tuners, webcams, video capturers
5bc5ca7149c00ac7c8f1920b323c27fbc24430c4
jacopo mondi
drivers
media
i2c
media: ov5647: break out format handling
break format handling out from the main driver structure.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
65
26
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +struct ov5647_mode { + struct v4l2_mbus_framefmt format; + const struct regval_list *reg_list; + unsigned int num_regs; +}; + +struct ov5647_format_list { + unsigned int mbus_code; + const struct ov5647_mode *modes; + unsigned int num_modes; +}; + - struct v4l2_mbus_framefmt format; - unsigned int width; - unsigned int height; + const struct ov5647_mode *mode; -static struct regval_list ov5647_640x480[] = { +static const struct regval_list ov5647_640x480[] = { +static const struct ov5647_mode ov5647_8bit_modes[] = { + { + .format = { + .code = media_bus_fmt_sbggr8_1x8, + .colorspace = v4l2_colorspace_srgb, + .field = v4l2_field_none, + .width = 640, + .height = 480 + }, + .reg_list = ov5647_640x480, + .num_regs = array_size(ov5647_640x480) + }, +}; + +static const struct ov5647_format_list ov5647_formats[] = { + { + .mbus_code = media_bus_fmt_sbggr8_1x8, + .modes = ov5647_8bit_modes, + .num_modes = array_size(ov5647_8bit_modes), + }, +}; + +#define ov5647_num_formats (array_size(ov5647_formats)) + +#define ov5647_default_mode (&ov5647_formats[0].modes[0]) +#define ov5647_default_format (ov5647_formats[0].modes[0].format) + - struct regval_list *regs, int array_size) + const struct regval_list *regs, int array_size) + struct ov5647 *sensor = to_sensor(sd); - ret = ov5647_write_array(sd, ov5647_640x480, - array_size(ov5647_640x480)); + ret = ov5647_write_array(sd, sensor->mode->reg_list, + sensor->mode->num_regs); - if (code->index > 0) + if (code->index >= ov5647_num_formats) - code->code = media_bus_fmt_sbggr8_1x8; + code->code = ov5647_formats[code->index].mbus_code; - if (fse->index) + const struct v4l2_mbus_framefmt *fmt; + unsigned int i = 0; + + for (; i < ov5647_num_formats; ++i) { + if (ov5647_formats[i].mbus_code == fse->code) + break; + } + if (i == ov5647_num_formats) - if (fse->code != media_bus_fmt_sbggr8_1x8) + if (fse->index >= ov5647_formats[i].num_modes) - fse->min_width = 640; - fse->max_width = 640; - fse->min_height = 480; - fse->max_height = 480; + fmt = &ov5647_formats[i].modes[fse->index].format; + fse->min_width = fmt->width; + fse->max_width = fmt->width; + fse->min_height = fmt->height; + fse->max_height = fmt->height; - memset(fmt, 0, sizeof(*fmt)); - fmt->code = media_bus_fmt_sbggr8_1x8; - fmt->colorspace = v4l2_colorspace_srgb; - fmt->field = v4l2_field_none; - fmt->width = 640; - fmt->height = 480; + *fmt = ov5647_default_format; - format->code = media_bus_fmt_sbggr8_1x8; - format->width = 640; - format->height = 480; - format->field = v4l2_field_none; - format->colorspace = v4l2_colorspace_srgb; + *format = ov5647_default_format; + sensor->mode = ov5647_default_mode; +
TV tuners, webcams, video capturers
d7d6074ecd496073fbffd740a9f40f24b25ad956
jacopo mondi
drivers
media
i2c
media: ov5647: add support for get_selection()
support the get_selection() pad operation to report the device full pixel array size, the currently applied analogue crop rectangle and the active pixel array dimensions.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
71
23
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c -#define ov5647_row_start 0x01 -#define ov5647_row_start_min 0 -#define ov5647_row_start_max 2004 -#define ov5647_row_start_def 54 - -#define ov5647_column_start 0x02 -#define ov5647_column_start_min 0 -#define ov5647_column_start_max 2750 -#define ov5647_column_start_def 16 - -#define ov5647_window_height 0x03 -#define ov5647_window_height_min 2 -#define ov5647_window_height_max 2006 -#define ov5647_window_height_def 1944 - -#define ov5647_window_width 0x04 -#define ov5647_window_width_min 2 -#define ov5647_window_width_max 2752 -#define ov5647_window_width_def 2592 +/* ov5647 native and active pixel array size */ +#define ov5647_native_width 2624u +#define ov5647_native_height 1956u + +#define ov5647_pixel_array_left 16u +#define ov5647_pixel_array_top 16u +#define ov5647_pixel_array_width 2592u +#define ov5647_pixel_array_height 1944u + struct v4l2_rect crop; + .crop = { + .left = ov5647_pixel_array_left, + .top = ov5647_pixel_array_top, + .width = 1280, + .height = 960, + }, +static const struct v4l2_rect * +__ov5647_get_pad_crop(struct ov5647 *ov5647, struct v4l2_subdev_pad_config *cfg, + unsigned int pad, enum v4l2_subdev_format_whence which) +{ + switch (which) { + case v4l2_subdev_format_try: + return v4l2_subdev_get_try_crop(&ov5647->sd, cfg, pad); + case v4l2_subdev_format_active: + return &ov5647->mode->crop; + } + + return null; +} + +static int ov5647_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case v4l2_sel_tgt_crop: { + struct ov5647 *sensor = to_sensor(sd); + + mutex_lock(&sensor->lock); + sel->r = *__ov5647_get_pad_crop(sensor, cfg, sel->pad, + sel->which); + mutex_unlock(&sensor->lock); + + return 0; + } + + case v4l2_sel_tgt_native_size: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = ov5647_native_width; + sel->r.height = ov5647_native_height; + + return 0; + + case v4l2_sel_tgt_crop_default: + case v4l2_sel_tgt_crop_bounds: + sel->r.top = ov5647_pixel_array_top; + sel->r.left = ov5647_pixel_array_left; + sel->r.width = ov5647_pixel_array_width; + sel->r.height = ov5647_pixel_array_height; + + return 0; + } + + return -einval; +} + + .get_selection = ov5647_get_selection, - crop->left = ov5647_column_start_def; - crop->top = ov5647_row_start_def; - crop->width = ov5647_window_width_def; - crop->height = ov5647_window_height_def; + crop->left = ov5647_pixel_array_left; + crop->top = ov5647_pixel_array_top; + crop->width = ov5647_pixel_array_width; + crop->height = ov5647_pixel_array_height;
TV tuners, webcams, video capturers
14f70a3232aa0a5a613cd0b690c962e1562f2baa
dave stevenson
drivers
media
i2c
media: ov5647: rename sbggr8 vga mode
before adding new modes, rename the only existing one to report the bit depth to distinguish it from future additions.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
7
6
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c -static const struct regval_list ov5647_640x480[] = { +static const struct regval_list ov5647_640x480_8bpp[] = { -static const struct ov5647_mode ov5647_8bit_modes[] = { +static const struct ov5647_mode ov5647_8bpp_modes[] = { + /* 8-bit vga mode: uncentred crop 2x2 binned 1296x972 image. */ - .reg_list = ov5647_640x480, - .num_regs = array_size(ov5647_640x480) + .reg_list = ov5647_640x480_8bpp, + .num_regs = array_size(ov5647_640x480_8bpp) - .modes = ov5647_8bit_modes, - .num_modes = array_size(ov5647_8bit_modes), + .modes = ov5647_8bpp_modes, + .num_modes = array_size(ov5647_8bpp_modes),
TV tuners, webcams, video capturers
e907bd662ebd6bf9d60b074c3b9f1facf8a12f8b
jacopo mondi
drivers
media
i2c
media: ov5647: add sggbr10_1x10 modes
add 4 additional sensor modes in sbggr10_1x10 format.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
441
0
- 2592x1944 full resolution - 1920x1080 1080p cropped - 1296x972 2x2 binned - 640x480 2x2 binned, 2x2 subsampled --- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c +static struct regval_list ov5647_2592x1944_10bpp[] = { + {0x0100, 0x00}, + {0x0103, 0x01}, + {0x3034, 0x1a}, + {0x3035, 0x21}, + {0x3036, 0x69}, + {0x303c, 0x11}, + {0x3106, 0xf5}, + {0x3821, 0x06}, + {0x3820, 0x00}, + {0x3827, 0xec}, + {0x370c, 0x03}, + {0x3612, 0x5b}, + {0x3618, 0x04}, + {0x5000, 0x06}, + {0x5002, 0x41}, + {0x5003, 0x08}, + {0x5a00, 0x08}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x00}, + {0x3016, 0x08}, + {0x3017, 0xe0}, + {0x3018, 0x44}, + {0x301c, 0xf8}, + {0x301d, 0xf0}, + {0x3a18, 0x00}, + {0x3a19, 0xf8}, + {0x3c01, 0x80}, + {0x3b07, 0x0c}, + {0x380c, 0x0b}, + {0x380d, 0x1c}, + {0x3814, 0x11}, + {0x3815, 0x11}, + {0x3708, 0x64}, + {0x3709, 0x12}, + {0x3808, 0x0a}, + {0x3809, 0x20}, + {0x380a, 0x07}, + {0x380b, 0x98}, + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0x0a}, + {0x3805, 0x3f}, + {0x3806, 0x07}, + {0x3807, 0xa3}, + {0x3811, 0x10}, + {0x3813, 0x06}, + {0x3630, 0x2e}, + {0x3632, 0xe2}, + {0x3633, 0x23}, + {0x3634, 0x44}, + {0x3636, 0x06}, + {0x3620, 0x64}, + {0x3621, 0xe0}, + {0x3600, 0x37}, + {0x3704, 0xa0}, + {0x3703, 0x5a}, + {0x3715, 0x78}, + {0x3717, 0x01}, + {0x3731, 0x02}, + {0x370b, 0x60}, + {0x3705, 0x1a}, + {0x3f05, 0x02}, + {0x3f06, 0x10}, + {0x3f01, 0x0a}, + {0x3a08, 0x01}, + {0x3a09, 0x28}, + {0x3a0a, 0x00}, + {0x3a0b, 0xf6}, + {0x3a0d, 0x08}, + {0x3a0e, 0x06}, + {0x3a0f, 0x58}, + {0x3a10, 0x50}, + {0x3a1b, 0x58}, + {0x3a1e, 0x50}, + {0x3a11, 0x60}, + {0x3a1f, 0x28}, + {0x4001, 0x02}, + {0x4004, 0x04}, + {0x4000, 0x09}, + {0x4837, 0x19}, + {0x4800, 0x24}, + {0x3503, 0x03}, + {0x0100, 0x01}, +}; + +static struct regval_list ov5647_1080p30_10bpp[] = { + {0x0100, 0x00}, + {0x0103, 0x01}, + {0x3034, 0x1a}, + {0x3035, 0x21}, + {0x3036, 0x62}, + {0x303c, 0x11}, + {0x3106, 0xf5}, + {0x3821, 0x06}, + {0x3820, 0x00}, + {0x3827, 0xec}, + {0x370c, 0x03}, + {0x3612, 0x5b}, + {0x3618, 0x04}, + {0x5000, 0x06}, + {0x5002, 0x41}, + {0x5003, 0x08}, + {0x5a00, 0x08}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x00}, + {0x3016, 0x08}, + {0x3017, 0xe0}, + {0x3018, 0x44}, + {0x301c, 0xf8}, + {0x301d, 0xf0}, + {0x3a18, 0x00}, + {0x3a19, 0xf8}, + {0x3c01, 0x80}, + {0x3b07, 0x0c}, + {0x380c, 0x09}, + {0x380d, 0x70}, + {0x3814, 0x11}, + {0x3815, 0x11}, + {0x3708, 0x64}, + {0x3709, 0x12}, + {0x3808, 0x07}, + {0x3809, 0x80}, + {0x380a, 0x04}, + {0x380b, 0x38}, + {0x3800, 0x01}, + {0x3801, 0x5c}, + {0x3802, 0x01}, + {0x3803, 0xb2}, + {0x3804, 0x08}, + {0x3805, 0xe3}, + {0x3806, 0x05}, + {0x3807, 0xf1}, + {0x3811, 0x04}, + {0x3813, 0x02}, + {0x3630, 0x2e}, + {0x3632, 0xe2}, + {0x3633, 0x23}, + {0x3634, 0x44}, + {0x3636, 0x06}, + {0x3620, 0x64}, + {0x3621, 0xe0}, + {0x3600, 0x37}, + {0x3704, 0xa0}, + {0x3703, 0x5a}, + {0x3715, 0x78}, + {0x3717, 0x01}, + {0x3731, 0x02}, + {0x370b, 0x60}, + {0x3705, 0x1a}, + {0x3f05, 0x02}, + {0x3f06, 0x10}, + {0x3f01, 0x0a}, + {0x3a08, 0x01}, + {0x3a09, 0x4b}, + {0x3a0a, 0x01}, + {0x3a0b, 0x13}, + {0x3a0d, 0x04}, + {0x3a0e, 0x03}, + {0x3a0f, 0x58}, + {0x3a10, 0x50}, + {0x3a1b, 0x58}, + {0x3a1e, 0x50}, + {0x3a11, 0x60}, + {0x3a1f, 0x28}, + {0x4001, 0x02}, + {0x4004, 0x04}, + {0x4000, 0x09}, + {0x4837, 0x19}, + {0x4800, 0x34}, + {0x3503, 0x03}, + {0x0100, 0x01}, +}; + +static struct regval_list ov5647_2x2binned_10bpp[] = { + {0x0100, 0x00}, + {0x0103, 0x01}, + {0x3034, 0x1a}, + {0x3035, 0x21}, + {0x3036, 0x62}, + {0x303c, 0x11}, + {0x3106, 0xf5}, + {0x3827, 0xec}, + {0x370c, 0x03}, + {0x3612, 0x59}, + {0x3618, 0x00}, + {0x5000, 0x06}, + {0x5002, 0x41}, + {0x5003, 0x08}, + {0x5a00, 0x08}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x00}, + {0x3016, 0x08}, + {0x3017, 0xe0}, + {0x3018, 0x44}, + {0x301c, 0xf8}, + {0x301d, 0xf0}, + {0x3a18, 0x00}, + {0x3a19, 0xf8}, + {0x3c01, 0x80}, + {0x3b07, 0x0c}, + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0x0a}, + {0x3805, 0x3f}, + {0x3806, 0x07}, + {0x3807, 0xa3}, + {0x3808, 0x05}, + {0x3809, 0x10}, + {0x380a, 0x03}, + {0x380b, 0xcc}, + {0x380c, 0x07}, + {0x380d, 0x68}, + {0x3811, 0x0c}, + {0x3813, 0x06}, + {0x3814, 0x31}, + {0x3815, 0x31}, + {0x3630, 0x2e}, + {0x3632, 0xe2}, + {0x3633, 0x23}, + {0x3634, 0x44}, + {0x3636, 0x06}, + {0x3620, 0x64}, + {0x3621, 0xe0}, + {0x3600, 0x37}, + {0x3704, 0xa0}, + {0x3703, 0x5a}, + {0x3715, 0x78}, + {0x3717, 0x01}, + {0x3731, 0x02}, + {0x370b, 0x60}, + {0x3705, 0x1a}, + {0x3f05, 0x02}, + {0x3f06, 0x10}, + {0x3f01, 0x0a}, + {0x3a08, 0x01}, + {0x3a09, 0x28}, + {0x3a0a, 0x00}, + {0x3a0b, 0xf6}, + {0x3a0d, 0x08}, + {0x3a0e, 0x06}, + {0x3a0f, 0x58}, + {0x3a10, 0x50}, + {0x3a1b, 0x58}, + {0x3a1e, 0x50}, + {0x3a11, 0x60}, + {0x3a1f, 0x28}, + {0x4001, 0x02}, + {0x4004, 0x04}, + {0x4000, 0x09}, + {0x4837, 0x16}, + {0x4800, 0x24}, + {0x3503, 0x03}, + {0x3820, 0x41}, + {0x3821, 0x07}, + {0x350a, 0x00}, + {0x350b, 0x10}, + {0x3500, 0x00}, + {0x3501, 0x1a}, + {0x3502, 0xf0}, + {0x3212, 0xa0}, + {0x0100, 0x01}, +}; + +static struct regval_list ov5647_640x480_10bpp[] = { + {0x0100, 0x00}, + {0x0103, 0x01}, + {0x3035, 0x11}, + {0x3036, 0x46}, + {0x303c, 0x11}, + {0x3821, 0x07}, + {0x3820, 0x41}, + {0x370c, 0x03}, + {0x3612, 0x59}, + {0x3618, 0x00}, + {0x5000, 0x06}, + {0x5003, 0x08}, + {0x5a00, 0x08}, + {0x3000, 0xff}, + {0x3001, 0xff}, + {0x3002, 0xff}, + {0x301d, 0xf0}, + {0x3a18, 0x00}, + {0x3a19, 0xf8}, + {0x3c01, 0x80}, + {0x3b07, 0x0c}, + {0x380c, 0x07}, + {0x380d, 0x3c}, + {0x3814, 0x35}, + {0x3815, 0x35}, + {0x3708, 0x64}, + {0x3709, 0x52}, + {0x3808, 0x02}, + {0x3809, 0x80}, + {0x380a, 0x01}, + {0x380b, 0xe0}, + {0x3800, 0x00}, + {0x3801, 0x10}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0x0a}, + {0x3805, 0x2f}, + {0x3806, 0x07}, + {0x3807, 0x9f}, + {0x3630, 0x2e}, + {0x3632, 0xe2}, + {0x3633, 0x23}, + {0x3634, 0x44}, + {0x3620, 0x64}, + {0x3621, 0xe0}, + {0x3600, 0x37}, + {0x3704, 0xa0}, + {0x3703, 0x5a}, + {0x3715, 0x78}, + {0x3717, 0x01}, + {0x3731, 0x02}, + {0x370b, 0x60}, + {0x3705, 0x1a}, + {0x3f05, 0x02}, + {0x3f06, 0x10}, + {0x3f01, 0x0a}, + {0x3a08, 0x01}, + {0x3a09, 0x2e}, + {0x3a0a, 0x00}, + {0x3a0b, 0xfb}, + {0x3a0d, 0x02}, + {0x3a0e, 0x01}, + {0x3a0f, 0x58}, + {0x3a10, 0x50}, + {0x3a1b, 0x58}, + {0x3a1e, 0x50}, + {0x3a11, 0x60}, + {0x3a1f, 0x28}, + {0x4001, 0x02}, + {0x4004, 0x02}, + {0x4000, 0x09}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x00}, + {0x3017, 0xe0}, + {0x301c, 0xfc}, + {0x3636, 0x06}, + {0x3016, 0x08}, + {0x3827, 0xec}, + {0x3018, 0x44}, + {0x3035, 0x21}, + {0x3106, 0xf5}, + {0x3034, 0x1a}, + {0x301c, 0xf8}, + {0x4800, 0x34}, + {0x3503, 0x03}, + {0x0100, 0x01}, +}; + +static const struct ov5647_mode ov5647_10bpp_modes[] = { + /* 2592x1944 full resolution full fov 10-bit mode. */ + { + .format = { + .code = media_bus_fmt_sbggr10_1x10, + .colorspace = v4l2_colorspace_srgb, + .field = v4l2_field_none, + .width = 2592, + .height = 1944 + }, + .crop = { + .left = ov5647_pixel_array_left, + .top = ov5647_pixel_array_top, + .width = 2592, + .height = 1944 + }, + .reg_list = ov5647_2592x1944_10bpp, + .num_regs = array_size(ov5647_2592x1944_10bpp) + }, + /* 1080p30 10-bit mode. full resolution centre-cropped down to 1080p. */ + { + .format = { + .code = media_bus_fmt_sbggr10_1x10, + .colorspace = v4l2_colorspace_srgb, + .field = v4l2_field_none, + .width = 1920, + .height = 1080 + }, + .crop = { + .left = 348 + ov5647_pixel_array_left, + .top = 434 + ov5647_pixel_array_top, + .width = 1928, + .height = 1080, + }, + .reg_list = ov5647_1080p30_10bpp, + .num_regs = array_size(ov5647_1080p30_10bpp) + }, + /* 2x2 binned full fov 10-bit mode. */ + { + .format = { + .code = media_bus_fmt_sbggr10_1x10, + .colorspace = v4l2_colorspace_srgb, + .field = v4l2_field_none, + .width = 1296, + .height = 972 + }, + .crop = { + .left = ov5647_pixel_array_left, + .top = ov5647_pixel_array_top, + .width = 2592, + .height = 1944, + }, + .reg_list = ov5647_2x2binned_10bpp, + .num_regs = array_size(ov5647_2x2binned_10bpp) + }, + /* 10-bit vga full fov 60fps. 2x2 binned and subsampled down to vga. */ + { + .format = { + .code = media_bus_fmt_sbggr10_1x10, + .colorspace = v4l2_colorspace_srgb, + .field = v4l2_field_none, + .width = 640, + .height = 480 + }, + .crop = { + .left = 16 + ov5647_pixel_array_left, + .top = ov5647_pixel_array_top, + .width = 2560, + .height = 1920, + }, + .reg_list = ov5647_640x480_10bpp, + .num_regs = array_size(ov5647_640x480_10bpp) + }, +}; + + { + .mbus_code = media_bus_fmt_sbggr10_1x10, + .modes = ov5647_10bpp_modes, + .num_modes = array_size(ov5647_10bpp_modes), + },
TV tuners, webcams, video capturers
a8df5af695a1ecd5077df18bd00375e24947b468
jacopo mondi
drivers
media
i2c
media: ov5647: use sbggr10_1x10 640x480 as default
the sbggr10_1x10 formats support more resolutions than sbggr8_1x8. make it the default sensor format and set 2x2 binned 640x480 resolution as default sensor size as it maximizes the fov and framerate.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
3
3
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c -#define ov5647_default_mode (&ov5647_formats[0].modes[0]) -#define ov5647_default_format (ov5647_formats[0].modes[0].format) +/* default sensor mode is 2x2 binned 640x480 sbggr10_1x10. */ +#define ov5647_default_mode (&ov5647_formats[1].modes[3]) +#define ov5647_default_format (ov5647_formats[1].modes[3].format) - /* only one format is supported, so return that. */
TV tuners, webcams, video capturers
87576ac69996fa3488424723723f7f8d2cebc3b3
jacopo mondi
drivers
media
i2c
media: ov5647: implement set_fmt pad operation
now that the driver supports more than a single mode, implement the .set_fmt pad operation and adjust the existing .get_fmt one to report the currently applied format.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
62
4
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c -static int ov5647_set_get_fmt(struct v4l2_subdev *sd, +static int ov5647_get_pad_fmt(struct v4l2_subdev *sd, + const struct v4l2_mbus_framefmt *sensor_format; + struct ov5647 *sensor = to_sensor(sd); + + mutex_lock(&sensor->lock); + switch (format->which) { + case v4l2_subdev_format_try: + sensor_format = v4l2_subdev_get_try_format(sd, cfg, format->pad); + break; + default: + sensor_format = &sensor->mode->format; + break; + } + + *fmt = *sensor_format; + mutex_unlock(&sensor->lock); + + return 0; +} + +static int ov5647_set_pad_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *format) +{ + struct v4l2_mbus_framefmt *fmt = &format->format; + const struct ov5647_mode *ov5647_mode_list; + struct ov5647 *sensor = to_sensor(sd); + const struct ov5647_mode *mode; + unsigned int num_modes; + unsigned int i; + + for (i = 0; i < ov5647_num_formats; ++i) { + if (ov5647_formats[i].mbus_code != fmt->code) + continue; + + ov5647_mode_list = ov5647_formats[i].modes; + num_modes = ov5647_formats[i].num_modes; + break; + } + + /* + * default mbus code media_bus_fmt_sbggr10_1x10 if the requested one is + * not supported. + */ + if (i == ov5647_num_formats) { + ov5647_mode_list = ov5647_10bpp_modes; + num_modes = array_size(ov5647_10bpp_modes); + } + + mode = v4l2_find_nearest_size(ov5647_mode_list, num_modes, + format.width, format.height, + fmt->width, fmt->height); - *fmt = ov5647_default_format; + /* update the sensor mode and apply at it at streamon time. */ + mutex_lock(&sensor->lock); + if (format->which == v4l2_subdev_format_try) + *v4l2_subdev_get_try_format(sd, cfg, format->pad) = mode->format; + else + sensor->mode = mode; + *fmt = mode->format; + mutex_unlock(&sensor->lock); - .set_fmt = ov5647_set_get_fmt, - .get_fmt = ov5647_set_get_fmt, + .set_fmt = ov5647_set_pad_fmt, + .get_fmt = ov5647_get_pad_fmt,
TV tuners, webcams, video capturers
6869e971b084ada46c42669822321560256ea085
jacopo mondi
drivers
media
i2c
media: ov5647: set v4l2_subdev_fl_has_events flag
the ov5647 subdev can generate control events, therefore set the v4l2_subdev_fl_has_events flag.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
1
1
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c - sd->flags |= v4l2_subdev_fl_has_devnode; + sd->flags |= v4l2_subdev_fl_has_devnode | v4l2_subdev_fl_has_events;
TV tuners, webcams, video capturers
7ef761a0015bf94d543aeb382610e0691e888287
dave stevenson
drivers
media
i2c
media: ov5647: support v4l2_cid_pixel_rate
clients need to know the pixel rate in order to compute exposure and frame rate values. advertise it.
this release allows to map an uid to a different one in a mount; it also adds support for selecting the preemption model at runtime; support for a low-overhead memory error detector designed to be used in production; support for the acrn hypervisor designed for embedded systems; btrfs initial support for zoned devices, subpage blocks sizes and performance improvements; support for eager nfs writes; support for a thermal power management to control the surface temperature of embedded devices in an unified way; the napi polling can be moved to a kernel thread; and support for non-blocking path lookups. as always, there are many other features, new drivers, improvements and fixes.
support raspberrypi camera module
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'cryptography', 'security', 'networking', 'architectures x86 arm risc-v powerpc mips csky s390 pa-risc c6x']
['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', 'cpu frequency scaling', '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', 'cryptography hardware acceleration', 'pci', 'non-transparent bridge (ntb)', 'thunderbolt', 'clock', 'phy ("physical layer" framework)', 'cxl (compute express link)', 'various']
['ov5647']
['c']
1
32
11
--- diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c + u64 pixel_rate; + struct v4l2_ctrl *pixel_rate; + .pixel_rate = 77291670, + .pixel_rate = 87500000, + .pixel_rate = 81666700, + .pixel_rate = 81666700, + .pixel_rate = 55000000, - if (format->which == v4l2_subdev_format_try) + if (format->which == v4l2_subdev_format_try) { - else + } else { + __v4l2_ctrl_modify_range(sensor->pixel_rate, mode->pixel_rate, + mode->pixel_rate, 1, mode->pixel_rate); + } + case v4l2_cid_pixel_rate: + /* read-only, but we adjust it based on mode. */ + return 0; - v4l2_ctrl_handler_init(&sensor->ctrls, 5); + v4l2_ctrl_handler_init(&sensor->ctrls, 6); - if (sensor->ctrls.error) { - dev_err(&client->dev, - "%s controls initialization failed (%d) ", - __func__, sensor->ctrls.error); - v4l2_ctrl_handler_free(&sensor->ctrls); - - return sensor->ctrls.error; - } + /* by default, pixel_rate is read only, but it does change per mode */ + sensor->pixel_rate = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops, + v4l2_cid_pixel_rate, + sensor->mode->pixel_rate, + sensor->mode->pixel_rate, 1, + sensor->mode->pixel_rate); + if (sensor->ctrls.error) + goto handler_free; + sensor->pixel_rate->flags |= v4l2_ctrl_flag_read_only; + +handler_free: + dev_err(&client->dev, "%s controls initialization failed (%d) ", + __func__, sensor->ctrls.error); + v4l2_ctrl_handler_free(&sensor->ctrls); + + return sensor->ctrls.error;
TV tuners, webcams, video capturers
911f4516ee2b940d0c27f994f77c0e702a004f86
dave stevenson
drivers
media
i2c