sound/soc/sdca/sdca_ump.c

Source file repositories/reference/linux-study-clean/sound/soc/sdca/sdca_ump.c

File Facts

System
Linux kernel
Corpus path
sound/soc/sdca/sdca_ump.c
Extension
.c
Size
8568 bytes
Lines
263
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2025 Cirrus Logic, Inc. and
//                    Cirrus Logic International Semiconductor Ltd.

/*
 * The MIPI SDCA specification is available for public downloads at
 * https://www.mipi.org/mipi-sdca-v1-0-download
 */

#include <linux/dev_printk.h>
#include <linux/device.h>
#include <linux/regmap.h>
#include <sound/sdca.h>
#include <sound/sdca_function.h>
#include <sound/sdca_ump.h>
#include <sound/soc-component.h>
#include <linux/soundwire/sdw_registers.h>

/**
 * sdca_ump_get_owner_host - check a UMP buffer is owned by the host
 * @dev: Pointer to the struct device used for error messages.
 * @function_regmap: Pointer to the regmap for the SDCA Function.
 * @function: Pointer to the Function information.
 * @entity: Pointer to the SDCA Entity.
 * @control: Pointer to the SDCA Control for the UMP Owner.
 *
 * Return: Returns zero on success, and a negative error code on failure.
 */
int sdca_ump_get_owner_host(struct device *dev,
			    struct regmap *function_regmap,
			    struct sdca_function_data *function,
			    struct sdca_entity *entity,
			    struct sdca_control *control)
{
	unsigned int reg, owner;
	int ret;

	reg = SDW_SDCA_CTL(function->desc->adr, entity->id, control->sel, 0);
	ret = regmap_read(function_regmap, reg, &owner);
	if (ret < 0) {
		dev_err(dev, "%s: failed to read UMP owner: %d\n",
			entity->label, ret);
		return ret;
	}

	if (owner != SDCA_UMP_OWNER_HOST) {
		dev_err(dev, "%s: host is not the UMP owner\n", entity->label);
		return -EINVAL;
	}

	return 0;
}
EXPORT_SYMBOL_NS_GPL(sdca_ump_get_owner_host, "SND_SOC_SDCA");

/**
 * sdca_ump_set_owner_device - set a UMP buffer's ownership back to the device
 * @dev: Pointer to the struct device used for error messages.
 * @function_regmap: Pointer to the regmap for the SDCA Function.
 * @function: Pointer to the Function information.
 * @entity: Pointer to the SDCA Entity.
 * @control: Pointer to the SDCA Control for the UMP Owner.
 *
 * Return: Returns zero on success, and a negative error code on failure.
 */
int sdca_ump_set_owner_device(struct device *dev,
			      struct regmap *function_regmap,
			      struct sdca_function_data *function,
			      struct sdca_entity *entity,
			      struct sdca_control *control)
{
	unsigned int reg;
	int ret;

	reg = SDW_SDCA_CTL(function->desc->adr, entity->id, control->sel, 0);
	ret = regmap_write(function_regmap, reg, SDCA_UMP_OWNER_DEVICE);
	if (ret < 0)
		dev_err(dev, "%s: failed to write UMP owner: %d\n",
			entity->label, ret);

	return ret;
}
EXPORT_SYMBOL_NS_GPL(sdca_ump_set_owner_device, "SND_SOC_SDCA");

/**
 * sdca_ump_read_message - read a UMP message from the device
 * @dev: Pointer to the struct device used for error messages.
 * @device_regmap: Pointer to the Device register map.
 * @function_regmap: Pointer to the regmap for the SDCA Function.
 * @function: Pointer to the Function information.
 * @entity: Pointer to the SDCA Entity.

Annotation

Implementation Notes