Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ed108c9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm: qdsp6v2: Add common items needed for Instance ID"

parents 5529a308 067a9285
Loading
Loading
Loading
Loading
+102 −0
Original line number Diff line number Diff line
@@ -29,6 +29,108 @@ struct param_outband {
	phys_addr_t  paddr;
};

/* --------- Common Structures and Definitions------------- */
/* Instance ID Definitions */
#define INSTANCE_ID_0 0x0000

struct mem_mapping_hdr {
	/*
	 * LSW of parameter data payload address. Supported values: any.
	 * - Must be set to zero for in-band data.
	 */
	u32 data_payload_addr_lsw;

	/*
	 * MSW of Parameter data payload address. Supported values: any.
	 * - Must be set to zero for in-band data.
	 * - In the case of 32 bit Shared memory address, msw  field must be
	 *   set to zero.
	 * - In the case of 36 bit shared memory address, bit 31 to bit 4 of
	 *   msw must be set to zero.
	 */
	u32 data_payload_addr_msw;

	/*
	 * Memory map handle returned by DSP through
	 * ASM_CMD_SHARED_MEM_MAP_REGIONS command.
	 * Supported Values: Any.
	 * If mmhandle is NULL, the ParamData payloads are within the
	 * message payload (in-band).
	 * If mmhandle is non-NULL, the ParamData payloads begin at the
	 * address specified in the address msw and lsw (out-of-band).
	 */
	u32 mem_map_handle;

} __packed;

/*
 * Payload format for parameter data.
 * Immediately following these structures are param_size bytes of parameter
 * data.
 */
struct param_hdr_v1 {
	/* Valid ID of the module. */
	uint32_t module_id;

	/* Valid ID of the parameter. */
	uint32_t param_id;

	/* The size of the parameter specified by the module/param ID combo */
	uint16_t param_size;

	/* This field must be set to zero. */
	uint16_t reserved;
} __packed;

struct param_hdr_v2 {
	/* Valid ID of the module. */
	uint32_t module_id;

	/* Valid ID of the parameter. */
	uint32_t param_id;

	/* The size of the parameter specified by the module/param ID combo */
	uint32_t param_size;
} __packed;

struct param_hdr_v3 {
	/* Valid ID of the module. */
	uint32_t module_id;

	/* Instance of the module. */
	uint16_t instance_id;

	/* This field must be set to zero. */
	uint16_t reserved;

	/* Valid ID of the parameter. */
	uint32_t param_id;

	/* The size of the parameter specified by the module/param ID combo */
	uint32_t param_size;
} __packed;

/* A union of all param_hdr versions for versitility and max size */
union param_hdrs {
	struct param_hdr_v1 v1;
	struct param_hdr_v2 v2;
	struct param_hdr_v3 v3;
};

struct module_instance_info {
	/* Module ID. */
	u32 module_id;

	/* Instance of the module */
	u16 instance_id;

	/* Reserved. This field must be set to zero. */
	u16 reserved;
} __packed;
/* -------------------------------------------------------- */

/* Begin service specific definitions and structures */

#define ADSP_ADM_VERSION    0x00070000

#define ADM_CMD_SHARED_MEM_MAP_REGIONS    0x00010322
+23 −0
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __Q6COMMON_H__
#define __Q6COMMON_H__

#include <sound/apr_audio-v2.h>

void q6common_update_instance_id_support(bool supported);
bool q6common_is_instance_id_supported(void);
int q6common_pack_pp_params(u8 *dest, struct param_hdr_v3 *v3_hdr,
			    u8 *param_data, u32 *total_size);

#endif /* __Q6COMMON_H__ */
+1 −1
Original line number Diff line number Diff line
@@ -19,6 +19,6 @@ obj-$(CONFIG_DTS_SRS_TM) += msm-dts-srs-tm-config.o
obj-$(CONFIG_QTI_PP) += msm-qti-pp-config.o
obj-y += audio_calibration.o audio_cal_utils.o q6adm.o q6afe.o q6asm.o \
	q6audio-v2.o q6voice.o q6core.o rtac.o q6lsm.o \
	msm-pcm-q6-noirq.o
	msm-pcm-q6-noirq.o q6common.o
ocmem-audio-objs += audio_ocmem.o
obj-$(CONFIG_AUDIO_OCMEM) += ocmem-audio.o
+46 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <sound/q6adm-v2.h>
#include <sound/q6asm-v2.h>
#include <sound/q6afe-v2.h>
#include <sound/q6common.h>
#include <sound/tlv.h>
#include <sound/asound.h>
#include <sound/pcm_params.h>
@@ -16426,6 +16427,47 @@ static const struct snd_kcontrol_new stereo_channel_reverse_control[] = {
	msm_routing_stereo_channel_reverse_control_put),
};
static int msm_routing_instance_id_support_info(struct snd_kcontrol *kcontrol,
						struct snd_ctl_elem_info *uinfo)
{
	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
	uinfo->count = 1;
	return 0;
}
static int msm_routing_instance_id_support_put(
	struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
	bool supported = ucontrol->value.integer.value[0] ? true : false;
	q6common_update_instance_id_support(supported);
	return 0;
}
static int msm_routing_instance_id_support_get(
	struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
	bool supported = false;
	supported = q6common_is_instance_id_supported();
	ucontrol->value.integer.value[0] = supported ? 1 : 0;
	return 0;
}
static const struct snd_kcontrol_new
	msm_routing_feature_support_mixer_controls[] = {
		{
			.access = SNDRV_CTL_ELEM_ACCESS_READ |
				  SNDRV_CTL_ELEM_ACCESS_WRITE,
			.info = msm_routing_instance_id_support_info,
			.name = "Instance ID Support",
			.put = msm_routing_instance_id_support_put,
			.get = msm_routing_instance_id_support_get,
		},
};
static struct snd_pcm_ops msm_routing_pcm_ops = {
	.hw_params	= msm_pcm_routing_hw_params,
	.close          = msm_pcm_routing_close,
@@ -16585,6 +16627,10 @@ static int msm_routing_probe(struct snd_soc_platform *platform)
					ARRAY_SIZE(aptx_dec_license_controls));
	snd_soc_add_platform_controls(platform, stereo_channel_reverse_control,
				ARRAY_SIZE(stereo_channel_reverse_control));
	snd_soc_add_platform_controls(
		platform, msm_routing_feature_support_mixer_controls,
		ARRAY_SIZE(msm_routing_feature_support_mixer_controls));
	return 0;
}
+85 −0
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <sound/q6common.h>

struct q6common_ctl {
	bool instance_id_supported;
};

static struct q6common_ctl common;

void q6common_update_instance_id_support(bool supported)
{
	common.instance_id_supported = supported;
}
EXPORT_SYMBOL(q6common_update_instance_id_support);

bool q6common_is_instance_id_supported(void)
{
	return common.instance_id_supported;
}
EXPORT_SYMBOL(q6common_is_instance_id_supported);

int q6common_pack_pp_params(u8 *dest, struct param_hdr_v3 *v3_hdr,
			    u8 *param_data, u32 *total_size)
{
	struct param_hdr_v1 *v1_hdr = NULL;
	u32 packed_size = 0;
	u32 param_size = 0;
	bool iid_supported = q6common_is_instance_id_supported();

	if (dest == NULL) {
		pr_err("%s: Received NULL pointer for destination\n", __func__);
		return -EINVAL;
	} else if (v3_hdr == NULL) {
		pr_err("%s: Received NULL pointer for header\n", __func__);
		return -EINVAL;
	} else if (total_size == NULL) {
		pr_err("%s: Received NULL pointer for total size\n", __func__);
		return -EINVAL;
	}

	param_size = v3_hdr->param_size;
	packed_size = iid_supported ? sizeof(struct param_hdr_v3) :
				      sizeof(struct param_hdr_v1);

	if (iid_supported) {
		memcpy(dest, v3_hdr, packed_size);
	} else {
		v1_hdr = (struct param_hdr_v1 *) dest;
		v1_hdr->module_id = v3_hdr->module_id;
		v1_hdr->param_id = v3_hdr->param_id;

		if (param_size > U16_MAX) {
			pr_err("%s: Invalid param size for V1 %d\n", __func__,
			       param_size);
			return -EINVAL;
		}
		v1_hdr->param_size = param_size;
		v1_hdr->reserved = 0;
	}

	/*
	 * Make param_data optional for cases when there is no data
	 * present as in some set cases and all get cases.
	 */
	if (param_data != NULL) {
		memcpy(dest + packed_size, param_data, param_size);
		packed_size += param_size;
	}

	*total_size = packed_size;

	return 0;
}
EXPORT_SYMBOL(q6common_pack_pp_params);