Add 'qcom/opensource/audio-kernel/' from commit '0ee387dfadf349618494d6f82ec8cec796ebef70'
git-subtree-dir: qcom/opensource/audio-kernel git-subtree-mainline:99ab089c55
git-subtree-split:0ee387dfad
Change-Id: repo: https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/audio-kernel-ar tag: AUDIO.LA.9.0.r1-07400-lanai.0
This commit is contained in:
213
qcom/opensource/audio-kernel/ipc/Kbuild
Normal file
213
qcom/opensource/audio-kernel/ipc/Kbuild
Normal file
@@ -0,0 +1,213 @@
|
||||
# We can build either as part of a standalone Kernel build or as
|
||||
# an external module. Determine which mechanism is being used
|
||||
ifeq ($(MODNAME),)
|
||||
KERNEL_BUILD := 1
|
||||
else
|
||||
KERNEL_BUILD := 0
|
||||
endif
|
||||
|
||||
# These are configurable via Kconfig for kernel-based builds
|
||||
# Need to explicitly configure for Android-based builds
|
||||
KDIR := $(TOP)/kernel/msm-5.4
|
||||
|
||||
ifeq ($(KERNEL_BUILD), 1)
|
||||
AUDIO_ROOT := $(KDIR)/techpack/audio
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SND_SOC_AUTO), y)
|
||||
ifdef CONFIG_SND_SOC_SA8155
|
||||
include $(AUDIO_ROOT)/config/sa8155auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sa8155autoconf.h
|
||||
endif
|
||||
ifdef CONFIG_SND_SOC_SA6155
|
||||
include $(AUDIO_ROOT)/config/sa6155auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sa6155autoconf.h
|
||||
endif
|
||||
ifdef CONFIG_SND_SOC_GVM
|
||||
include $(AUDIO_ROOT)/config/gvmauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/gvmautoconf.h
|
||||
endif
|
||||
ifdef CONFIG_SND_SOC_SA7255
|
||||
include $(AUDIO_ROOT)/config/sa7255auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sa7255autoconf.h
|
||||
endif
|
||||
else
|
||||
ifeq ($(KERNEL_BUILD), 0)
|
||||
ifeq ($(CONFIG_ARCH_SM6150), y)
|
||||
ifdef CONFIG_SND_SOC_SA6155
|
||||
include $(AUDIO_ROOT)/config/sa6155auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sa6155autoconf.h
|
||||
else
|
||||
include $(AUDIO_ROOT)/config/sm6150auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sm6150autoconf.h
|
||||
endif
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_TRINKET), y)
|
||||
include $(AUDIO_ROOT)/config/sm6150auto.conf
|
||||
export
|
||||
INCS += -include $(AUDIO_ROOT)/config/sm6150autoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_KONA), y)
|
||||
include $(AUDIO_ROOT)/config/konaauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/konaautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_WAIPIO), y)
|
||||
include $(AUDIO_ROOT)/config/waipioauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/waipioautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_KALAMA), y)
|
||||
include $(AUDIO_ROOT)/config/kalamaauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/kalamaautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_PINEAPPLE), y)
|
||||
include $(AUDIO_ROOT)/config/pineappleauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/pineappleautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_PITTI), y)
|
||||
include $(AUDIO_ROOT)/config/pittiauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/pittiautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_LITO), y)
|
||||
include $(AUDIO_ROOT)/config/litoauto.conf
|
||||
export
|
||||
INCS += -include $(AUDIO_ROOT)/config/litoautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_KHAJE), y)
|
||||
include $(AUDIO_ROOT)/config/bengalauto.conf
|
||||
export
|
||||
INCS += -include $(AUDIO_ROOT)/config/bengalautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_HOLI), y)
|
||||
include $(AUDIO_ROOT)/config/holiauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/holiautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_BLAIR), y)
|
||||
include $(AUDIO_ROOT)/config/holiauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/holiautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_SM8150), y)
|
||||
ifdef CONFIG_SND_SOC_SA8155
|
||||
include $(AUDIO_ROOT)/config/sa8155auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sa8155autoconf.h
|
||||
else
|
||||
include $(AUDIO_ROOT)/config/sm8150auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sm8150autoconf.h
|
||||
endif
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_QCS405), y)
|
||||
include $(AUDIO_ROOT)/config/qcs405auto.conf
|
||||
export
|
||||
INCS += -include $(AUDIO_ROOT)/config/qcs405autoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_SDMSHRIKE), y)
|
||||
ifdef CONFIG_SND_SOC_SA8155
|
||||
include $(AUDIO_ROOT)/config/sa8155auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sa8155autoconf.h
|
||||
else
|
||||
include $(AUDIO_ROOT)/config/sm8150auto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/sm8150autoconf.h
|
||||
endif
|
||||
endif
|
||||
ifeq ($(CONFIG_QTI_QUIN_GVM), y)
|
||||
include $(AUDIO_ROOT)/config/gvmauto.conf
|
||||
INCS += -include $(AUDIO_ROOT)/config/gvmautoconf.h
|
||||
endif
|
||||
ifeq ($(CONFIG_ARCH_SDXLEMUR), y)
|
||||
include $(AUDIO_ROOT)/config/sdxlemurauto.conf
|
||||
export
|
||||
INCS += -include $(AUDIO_ROOT)/config/sdxlemurautoconf.h
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# As per target team, build is done as follows:
|
||||
# Defconfig : build with default flags
|
||||
# Slub : defconfig + CONFIG_SLUB_DEBUG := y +
|
||||
# CONFIG_SLUB_DEBUG_ON := y + CONFIG_PAGE_POISONING := y
|
||||
# Perf : Using appropriate msmXXXX-perf_defconfig
|
||||
#
|
||||
# Shipment builds (user variants) should not have any debug feature
|
||||
# enabled. This is identified using 'TARGET_BUILD_VARIANT'. Slub builds
|
||||
# are identified using the CONFIG_SLUB_DEBUG_ON configuration. Since
|
||||
# there is no other way to identify defconfig builds, QTI internal
|
||||
# representation of perf builds (identified using the string 'perf'),
|
||||
# is used to identify if the build is a slub or defconfig one. This
|
||||
# way no critical debug feature will be enabled for perf and shipment
|
||||
# builds. Other OEMs are also protected using the TARGET_BUILD_VARIANT
|
||||
# config.
|
||||
|
||||
############ UAPI ############
|
||||
UAPI_DIR := uapi/audio
|
||||
UAPI_INC := -I$(AUDIO_ROOT)/include/$(UAPI_DIR)
|
||||
|
||||
############ COMMON ############
|
||||
COMMON_DIR := include
|
||||
COMMON_INC := -I$(AUDIO_ROOT)/$(COMMON_DIR)
|
||||
|
||||
############ IPC ############
|
||||
|
||||
ifdef CONFIG_MSM_QDSP6_GPR_RPMSG
|
||||
GPRV_GLINK += gpr-lite.o
|
||||
endif
|
||||
|
||||
ifdef CONFIG_AUDIO_PKT
|
||||
AUDIO_PKT += audio-pkt.o
|
||||
endif
|
||||
|
||||
LINUX_INC += -Iinclude/linux
|
||||
|
||||
INCS += $(COMMON_INC) \
|
||||
$(UAPI_INC)
|
||||
|
||||
EXTRA_CFLAGS += $(INCS)
|
||||
|
||||
|
||||
CDEFINES += -DANI_LITTLE_BYTE_ENDIAN \
|
||||
-DANI_LITTLE_BIT_ENDIAN \
|
||||
-DDOT11F_LITTLE_ENDIAN_HOST \
|
||||
-DANI_COMPILER_TYPE_GCC \
|
||||
-DANI_OS_TYPE_ANDROID=6 \
|
||||
-DPTT_SOCK_SVC_ENABLE \
|
||||
-Wall\
|
||||
-Werror\
|
||||
-D__linux__
|
||||
|
||||
KBUILD_CPPFLAGS += $(CDEFINES)
|
||||
|
||||
|
||||
# Currently, for versions of gcc which support it, the kernel Makefile
|
||||
# is disabling the maybe-uninitialized warning. Re-enable it for the
|
||||
# AUDIO driver. Note that we must use EXTRA_CFLAGS here so that it
|
||||
# will override the kernel settings.
|
||||
ifeq ($(call cc-option-yn, -Wmaybe-uninitialized),y)
|
||||
EXTRA_CFLAGS += -Wmaybe-uninitialized
|
||||
endif
|
||||
#EXTRA_CFLAGS += -Wmissing-prototypes
|
||||
|
||||
ifeq ($(call cc-option-yn, -Wheader-guard),y)
|
||||
EXTRA_CFLAGS += -Wheader-guard
|
||||
endif
|
||||
# If the module name is not "wlan", then the define MULTI_IF_NAME to be the
|
||||
# same a the QCA CHIP name. The host driver will then append MULTI_IF_NAME to
|
||||
# any string that must be unique for all instances of the driver on the system.
|
||||
# This allows multiple instances of the driver with different module names.
|
||||
# If the module name is wlan, leave MULTI_IF_NAME undefined and the code will
|
||||
# treat the driver as the primary driver.
|
||||
ifneq ($(MODNAME), qdsp6v2)
|
||||
CHIP_NAME ?= $(MODNAME)
|
||||
CDEFINES += -DMULTI_IF_NAME=\"$(CHIP_NAME)\"
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SND_SOC_GCOV), y)
|
||||
GCOV_PROFILE := y
|
||||
endif
|
||||
|
||||
# Module information used by KBuild framework
|
||||
obj-$(CONFIG_MSM_QDSP6_GPR_RPMSG) += gpr_dlkm.o
|
||||
gpr_dlkm-y := $(GPRV_GLINK)
|
||||
|
||||
obj-$(CONFIG_AUDIO_PKT) += audio_pkt_dlkm.o
|
||||
audio_pkt_dlkm-y := $(AUDIO_PKT)
|
||||
|
||||
# inject some build related information
|
||||
CDEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"
|
6
qcom/opensource/audio-kernel/ipc/Makefile
Normal file
6
qcom/opensource/audio-kernel/ipc/Makefile
Normal file
@@ -0,0 +1,6 @@
|
||||
modules:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS) VERBOSE=1
|
||||
modules_install:
|
||||
$(MAKE) M=$(M) -C $(KERNEL_SRC) modules_install
|
||||
clean:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) clean
|
761
qcom/opensource/audio-kernel/ipc/audio-pkt.c
Executable file
761
qcom/opensource/audio-kernel/ipc/audio-pkt.c
Executable file
@@ -0,0 +1,761 @@
|
||||
/* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. 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 <linux/platform_device.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/ipc_logging.h>
|
||||
#include <linux/refcount.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/cdev.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/termios.h>
|
||||
#include <ipc/gpr-lite.h>
|
||||
#include <dsp/spf-core.h>
|
||||
#include <dsp/msm_audio_ion.h>
|
||||
|
||||
/* Define IPC Logging Macros */
|
||||
#define AUDIO_PKT_IPC_LOG_PAGE_CNT 2
|
||||
static void *audio_pkt_ilctxt;
|
||||
|
||||
static int audio_pkt_debug_mask;
|
||||
module_param_named(debug_mask, audio_pkt_debug_mask, int, 0664);
|
||||
|
||||
#define APM_CMD_SHARED_MEM_MAP_REGIONS 0x0100100C
|
||||
#define APM_MEMORY_MAP_BIT_MASK_IS_OFFSET_MODE 0x00000004UL
|
||||
enum {
|
||||
AUDIO_PKT_INFO = 1U << 0,
|
||||
};
|
||||
|
||||
#define AUDIO_PKT_INFO(x, ...) \
|
||||
do { \
|
||||
if (audio_pkt_debug_mask & AUDIO_PKT_INFO) { \
|
||||
ipc_log_string(audio_pkt_ilctxt, \
|
||||
"[%s]: "x, __func__, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define AUDIO_PKT_ERR(x, ...) \
|
||||
do { \
|
||||
pr_err_ratelimited("[%s]: "x, __func__, ##__VA_ARGS__); \
|
||||
ipc_log_string(audio_pkt_ilctxt, "[%s]: "x, __func__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define MODULE_NAME "audio-pkt"
|
||||
#define MINOR_NUMBER_COUNT 1
|
||||
#define AUDPKT_DRIVER_NAME "aud_pasthru_adsp"
|
||||
#define CHANNEL_NAME "adsp_apps"
|
||||
#define MAX_PACKET_SIZE 4096
|
||||
|
||||
|
||||
enum audio_pkt_state {
|
||||
AUDIO_PKT_INIT,
|
||||
AUDIO_PKT_PROBED,
|
||||
AUDIO_PKT_REMOVED,
|
||||
AUDIO_PKT_DEINIT,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct audio_pkt_device - driver context, relates to platform dev
|
||||
* @dev: audio pkt device
|
||||
* @cdev: cdev for the audio pkt device
|
||||
* @lock: synchronization of @dev
|
||||
* @queue_lock: synchronization of @queue operations
|
||||
* @queue: incoming message queue
|
||||
* @readq: wait object for incoming queue
|
||||
* @dev_name: /dev/@dev_name for audio_pkt device
|
||||
* @ch_name: audio channel to match to
|
||||
* @audio_pkt_major: Major number of audio pkt driver
|
||||
* @audio_pkt_class: audio pkt class pointer
|
||||
*/
|
||||
struct audio_pkt_device {
|
||||
struct device *dev;
|
||||
struct cdev cdev;
|
||||
|
||||
struct mutex lock;
|
||||
spinlock_t queue_lock;
|
||||
struct sk_buff_head queue;
|
||||
wait_queue_head_t readq;
|
||||
|
||||
char dev_name[20];
|
||||
char ch_name[20];
|
||||
|
||||
dev_t audio_pkt_major;
|
||||
struct class *audio_pkt_class;
|
||||
};
|
||||
|
||||
struct audio_pkt_priv {
|
||||
struct gpr_device *adev;
|
||||
struct device *dev;
|
||||
struct audio_pkt_device *ap_dev;
|
||||
|
||||
struct mutex lock;
|
||||
enum audio_pkt_state status;
|
||||
};
|
||||
|
||||
static struct audio_pkt_priv *ap_priv;
|
||||
|
||||
|
||||
struct audio_pkt_apm_cmd_shared_mem_map_regions_t {
|
||||
uint16_t mem_pool_id;
|
||||
uint16_t num_regions;
|
||||
uint32_t property_flag;
|
||||
|
||||
};
|
||||
|
||||
struct audio_pkt_apm_shared_map_region_payload_t {
|
||||
uint32_t shm_addr_lsw;
|
||||
uint32_t shm_addr_msw;
|
||||
uint32_t mem_size_bytes;
|
||||
};
|
||||
|
||||
struct audio_pkt_apm_mem_map {
|
||||
struct audio_pkt_apm_cmd_shared_mem_map_regions_t mmap_header;
|
||||
struct audio_pkt_apm_shared_map_region_payload_t mmap_payload;
|
||||
};
|
||||
|
||||
struct audio_gpr_pkt {
|
||||
struct gpr_hdr audpkt_hdr;
|
||||
struct audio_pkt_apm_mem_map audpkt_mem_map;
|
||||
};
|
||||
|
||||
typedef void (*audio_pkt_clnt_cb_fn)(void *buf, int len, void *priv);
|
||||
|
||||
struct audio_pkt_clnt_ch {
|
||||
int client_id;
|
||||
audio_pkt_clnt_cb_fn func;
|
||||
};
|
||||
|
||||
/**
|
||||
* audio_pkt_open() - open() syscall for the audio_pkt device
|
||||
* inode: Pointer to the inode structure.
|
||||
* file: Pointer to the file structure.
|
||||
*
|
||||
* This function is used to open the audio pkt device when
|
||||
* userspace client do a open() system call. All input arguments are
|
||||
* validated by the virtual file system before calling this function.
|
||||
*/
|
||||
int audio_pkt_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct audio_pkt_device *audpkt_dev = ap_priv->ap_dev;
|
||||
AUDIO_PKT_INFO("%s: for %s \n", __func__,audpkt_dev->ch_name);
|
||||
file->private_data = ap_priv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_release() - release operation on audio_pkt device
|
||||
* inode: Pointer to the inode structure.
|
||||
* file: Pointer to the file structure.
|
||||
*
|
||||
* This function is used to release the audio pkt device when
|
||||
* userspace client do a close() system call. All input arguments are
|
||||
* validated by the virtual file system before calling this function.
|
||||
*/
|
||||
int audio_pkt_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct audio_pkt_priv *ap_priv = file->private_data;
|
||||
struct audio_pkt_device *audpkt_dev = ap_priv->ap_dev;
|
||||
|
||||
struct sk_buff *skb;
|
||||
unsigned long flags;
|
||||
|
||||
if ((!audpkt_dev)) {
|
||||
AUDIO_PKT_ERR("invalid device handle\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
AUDIO_PKT_INFO("%s: for %s \n", __func__,audpkt_dev->ch_name);
|
||||
spin_lock_irqsave(&audpkt_dev->queue_lock, flags);
|
||||
|
||||
/* Discard all SKBs */
|
||||
while (!skb_queue_empty(&audpkt_dev->queue)) {
|
||||
skb = skb_dequeue(&audpkt_dev->queue);
|
||||
kfree_skb(skb);
|
||||
}
|
||||
wake_up_interruptible(&audpkt_dev->readq);
|
||||
spin_unlock_irqrestore(&audpkt_dev->queue_lock, flags);
|
||||
|
||||
file->private_data = NULL;
|
||||
spf_core_apm_close_all();
|
||||
msm_audio_ion_crash_handler();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int audio_pkt_internal_release(struct platform_device *adev)
|
||||
{
|
||||
struct audio_pkt_priv *ap_priv = platform_get_drvdata(adev);
|
||||
struct audio_pkt_device *audpkt_dev = ap_priv->ap_dev;
|
||||
struct sk_buff *skb;
|
||||
unsigned long flags;
|
||||
|
||||
if ((!audpkt_dev)) {
|
||||
AUDIO_PKT_ERR("invalid device handle\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
AUDIO_PKT_INFO("%s: for %s\n", __func__,audpkt_dev->ch_name);
|
||||
spin_lock_irqsave(&audpkt_dev->queue_lock, flags);
|
||||
/* Discard all SKBs */
|
||||
while (!skb_queue_empty(&audpkt_dev->queue)) {
|
||||
skb = skb_dequeue(&audpkt_dev->queue);
|
||||
kfree_skb(skb);
|
||||
}
|
||||
spin_unlock_irqrestore(&audpkt_dev->queue_lock, flags);
|
||||
|
||||
wake_up_interruptible(&audpkt_dev->readq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_read() - read() syscall for the audio_pkt device
|
||||
* file: Pointer to the file structure.
|
||||
* buf: Pointer to the userspace buffer.
|
||||
* count: Number bytes to read from the file.
|
||||
* ppos: Pointer to the position into the file.
|
||||
*
|
||||
* This function is used to Read the data from audio pkt device when
|
||||
* userspace client do a read() system call. All input arguments are
|
||||
* validated by the virtual file system before calling this function.
|
||||
*/
|
||||
ssize_t audio_pkt_read(struct file *file, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct audio_pkt_priv *ap_priv = file->private_data;
|
||||
struct audio_pkt_device *audpkt_dev = ap_priv->ap_dev;
|
||||
|
||||
unsigned long flags;
|
||||
struct sk_buff *skb;
|
||||
int use;
|
||||
uint32_t *temp;
|
||||
|
||||
if (!audpkt_dev) {
|
||||
AUDIO_PKT_ERR("invalid device handle\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&ap_priv->lock);
|
||||
if (AUDIO_PKT_PROBED != ap_priv->status)
|
||||
{
|
||||
mutex_unlock(&ap_priv->lock);
|
||||
AUDIO_PKT_ERR("dev is in reset\n");
|
||||
return -ENETRESET;
|
||||
}
|
||||
mutex_unlock(&ap_priv->lock);
|
||||
|
||||
spin_lock_irqsave(&audpkt_dev->queue_lock, flags);
|
||||
/* Wait for data in the queue */
|
||||
if (skb_queue_empty(&audpkt_dev->queue)) {
|
||||
spin_unlock_irqrestore(&audpkt_dev->queue_lock, flags);
|
||||
|
||||
if (file->f_flags & O_NONBLOCK)
|
||||
return -EAGAIN;
|
||||
|
||||
/* Wait until we get data or the endpoint goes away */
|
||||
if (wait_event_interruptible(audpkt_dev->readq,
|
||||
!skb_queue_empty(&audpkt_dev->queue)))
|
||||
return -ERESTARTSYS;
|
||||
|
||||
spin_lock_irqsave(&audpkt_dev->queue_lock, flags);
|
||||
}
|
||||
|
||||
skb = skb_dequeue(&audpkt_dev->queue);
|
||||
spin_unlock_irqrestore(&audpkt_dev->queue_lock, flags);
|
||||
if (!skb)
|
||||
return -EFAULT;
|
||||
|
||||
use = min_t(size_t, count, skb->len);
|
||||
if (copy_to_user(buf, skb->data, use))
|
||||
use = -EFAULT;
|
||||
temp = (uint32_t *) skb->data;
|
||||
kfree_skb(skb);
|
||||
|
||||
return use;
|
||||
}
|
||||
|
||||
/**
|
||||
* audpkt_update_physical_addr - Update physical address
|
||||
* audpkt_hdr: Pointer to the file structure.
|
||||
*/
|
||||
int audpkt_chk_and_update_physical_addr(struct audio_gpr_pkt *gpr_pkt)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t pa_len = 0;
|
||||
dma_addr_t paddr;
|
||||
|
||||
if (gpr_pkt->audpkt_mem_map.mmap_header.property_flag &
|
||||
APM_MEMORY_MAP_BIT_MASK_IS_OFFSET_MODE) {
|
||||
ret = msm_audio_get_phy_addr(
|
||||
(int) gpr_pkt->audpkt_mem_map.mmap_payload.shm_addr_lsw,
|
||||
&paddr, &pa_len);
|
||||
if (ret < 0) {
|
||||
AUDIO_PKT_ERR("%s Get phy. address failed, ret %d\n",
|
||||
__func__, ret);
|
||||
return ret;
|
||||
}
|
||||
AUDIO_PKT_INFO("%s physical address %pK", __func__,
|
||||
(void *) paddr);
|
||||
gpr_pkt->audpkt_mem_map.mmap_payload.shm_addr_lsw = (uint32_t) paddr;
|
||||
gpr_pkt->audpkt_mem_map.mmap_payload.shm_addr_msw = (uint64_t) paddr >> 32;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_write() - write() syscall for the audio_pkt device
|
||||
* file: Pointer to the file structure.
|
||||
* buf: Pointer to the userspace buffer.
|
||||
* count: Number bytes to read from the file.
|
||||
* ppos: Pointer to the position into the file.
|
||||
*
|
||||
* This function is used to write the data to audio pkt device when
|
||||
* userspace client do a write() system call. All input arguments are
|
||||
* validated by the virtual file system before calling this function.
|
||||
*/
|
||||
ssize_t audio_pkt_write(struct file *file, const char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct audio_pkt_priv *ap_priv = NULL;
|
||||
struct audio_pkt_device *audpkt_dev = NULL;
|
||||
struct gpr_hdr *audpkt_hdr = NULL;
|
||||
void *kbuf;
|
||||
int ret;
|
||||
|
||||
if (file == NULL || file->private_data == NULL || buf == NULL) {
|
||||
AUDIO_PKT_ERR("invalid parameters\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
ap_priv = file->private_data;
|
||||
audpkt_dev = ap_priv->ap_dev;
|
||||
|
||||
if (!audpkt_dev) {
|
||||
AUDIO_PKT_ERR("invalid device handle\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&ap_priv->lock);
|
||||
if (AUDIO_PKT_PROBED != ap_priv->status)
|
||||
{
|
||||
mutex_unlock(&ap_priv->lock);
|
||||
AUDIO_PKT_ERR("dev is in reset\n");
|
||||
return -ENETRESET;
|
||||
}
|
||||
mutex_unlock(&ap_priv->lock);
|
||||
if (count < sizeof(struct gpr_hdr)) {
|
||||
AUDIO_PKT_ERR("Invalid count %zu\n", count);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
kbuf = memdup_user(buf, count);
|
||||
if (IS_ERR(kbuf))
|
||||
return PTR_ERR(kbuf);
|
||||
|
||||
audpkt_hdr = (struct gpr_hdr *) kbuf;
|
||||
|
||||
/* validate packet size */
|
||||
if ((count > MAX_PACKET_SIZE) || (count < GPR_PKT_GET_PACKET_BYTE_SIZE(audpkt_hdr->header)))
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto free_kbuf;
|
||||
}
|
||||
|
||||
if (audpkt_hdr->opcode == APM_CMD_SHARED_MEM_MAP_REGIONS) {
|
||||
if (count < sizeof(struct audio_gpr_pkt)) {
|
||||
AUDIO_PKT_ERR("Invalid count %zu\n", count);
|
||||
ret = -EINVAL;
|
||||
goto free_kbuf;
|
||||
}
|
||||
ret = audpkt_chk_and_update_physical_addr((struct audio_gpr_pkt *) audpkt_hdr);
|
||||
if (ret < 0) {
|
||||
AUDIO_PKT_ERR("Update Physical Address Failed -%d\n", ret);
|
||||
goto free_kbuf;
|
||||
}
|
||||
}
|
||||
|
||||
if (mutex_lock_interruptible(&audpkt_dev->lock)) {
|
||||
ret = -ERESTARTSYS;
|
||||
goto free_kbuf;
|
||||
}
|
||||
if (count < sizeof(struct gpr_pkt )) {
|
||||
AUDIO_PKT_ERR("Invalid count %zu\n", count);
|
||||
ret = -EINVAL;
|
||||
mutex_unlock(&audpkt_dev->lock);
|
||||
goto free_kbuf;
|
||||
}
|
||||
ret = gpr_send_pkt(ap_priv->adev,(struct gpr_pkt *) kbuf);
|
||||
if (ret < 0) {
|
||||
AUDIO_PKT_ERR("APR Send Packet Failed ret -%d\n", ret);
|
||||
if (ret == -ECONNRESET)
|
||||
ret = -ENETRESET;
|
||||
}
|
||||
mutex_unlock(&audpkt_dev->lock);
|
||||
|
||||
free_kbuf:
|
||||
kfree(kbuf);
|
||||
return ret < 0 ? ret : count;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_poll() - poll() syscall for the audio_pkt device
|
||||
* file: Pointer to the file structure.
|
||||
* wait: pointer to Poll table.
|
||||
*
|
||||
* This function is used to poll on the audio pkt device when
|
||||
* userspace client do a poll() system call. All input arguments are
|
||||
* validated by the virtual file system before calling this function.
|
||||
*/
|
||||
static unsigned int audio_pkt_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
struct audio_pkt_priv *ap_priv = file->private_data;
|
||||
struct audio_pkt_device *audpkt_dev = ap_priv->ap_dev;
|
||||
unsigned int mask = 0;
|
||||
unsigned long flags;
|
||||
if (!audpkt_dev) {
|
||||
AUDIO_PKT_ERR("invalid device handle\n");
|
||||
return POLLERR;
|
||||
}
|
||||
|
||||
poll_wait(file, &audpkt_dev->readq, wait);
|
||||
mutex_lock(&audpkt_dev->lock);
|
||||
|
||||
spin_lock_irqsave(&audpkt_dev->queue_lock, flags);
|
||||
if (!skb_queue_empty(&audpkt_dev->queue))
|
||||
mask |= POLLIN | POLLRDNORM;
|
||||
|
||||
spin_unlock_irqrestore(&audpkt_dev->queue_lock, flags);
|
||||
mutex_unlock(&audpkt_dev->lock);
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static const struct file_operations audio_pkt_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = audio_pkt_open,
|
||||
.release = audio_pkt_release,
|
||||
.read = audio_pkt_read,
|
||||
.write = audio_pkt_write,
|
||||
.poll = audio_pkt_poll,
|
||||
};
|
||||
|
||||
/**
|
||||
* audio_pkt_srvc_callback() - Callback from gpr driver
|
||||
* adev: pointer to the gpr device of this audio packet device
|
||||
* data: APR response data packet
|
||||
*
|
||||
* return: 0 for success, Standard Linux errors
|
||||
*/
|
||||
static int audio_pkt_srvc_callback(struct gpr_device *adev,
|
||||
void *data)
|
||||
{
|
||||
struct audio_pkt_priv *ap_priv = dev_get_drvdata(&adev->dev);
|
||||
struct audio_pkt_device *audpkt_dev = ap_priv->ap_dev;
|
||||
|
||||
unsigned long flags;
|
||||
struct sk_buff *skb;
|
||||
struct gpr_hdr *hdr = (struct gpr_hdr *)data;
|
||||
uint16_t hdr_size, pkt_size;
|
||||
hdr_size = GPR_PKT_GET_HEADER_BYTE_SIZE(hdr->header);
|
||||
pkt_size = GPR_PKT_GET_PACKET_BYTE_SIZE(hdr->header);
|
||||
|
||||
AUDIO_PKT_INFO("%s: header %d packet %d \n",
|
||||
__func__,hdr_size, pkt_size);
|
||||
|
||||
skb = alloc_skb(pkt_size, GFP_ATOMIC);
|
||||
if (!skb)
|
||||
return -ENOMEM;
|
||||
|
||||
skb_put_data(skb, data, pkt_size);
|
||||
|
||||
spin_lock_irqsave(&audpkt_dev->queue_lock, flags);
|
||||
skb_queue_tail(&audpkt_dev->queue, skb);
|
||||
spin_unlock_irqrestore(&audpkt_dev->queue_lock, flags);
|
||||
|
||||
/* wake up any blocking processes, waiting for new data */
|
||||
wake_up_interruptible(&audpkt_dev->readq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_probe() - Probe a AUDIO packet device
|
||||
*
|
||||
* adev: Pointer to gpr device.
|
||||
*
|
||||
* return: 0 on success, standard Linux error codes on error.
|
||||
*
|
||||
* This function is called when the underlying device tree driver registers
|
||||
* a gpr device, mapped to a Audio packet device.
|
||||
*/
|
||||
static int audio_pkt_probe(struct gpr_device *adev)
|
||||
{
|
||||
if(ap_priv)
|
||||
{
|
||||
mutex_lock(&ap_priv->lock);
|
||||
ap_priv->adev = adev;
|
||||
ap_priv->status = AUDIO_PKT_PROBED;
|
||||
mutex_unlock(&ap_priv->lock);
|
||||
|
||||
dev_set_drvdata(&adev->dev, ap_priv);
|
||||
|
||||
dev_dbg(&adev->dev, "%s: Driver[%s] Probed\n",
|
||||
__func__, adev->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
dev_err(&adev->dev, "%s: Driver[%s] Probe Failed\n",
|
||||
__func__, adev->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_remove() - Remove a AUDIO packet device
|
||||
*
|
||||
* adev: Pointer to gpr device.
|
||||
*
|
||||
* return: 0 on success, standard Linux error codes on error.
|
||||
*
|
||||
* This function is called when the underlying device tree driver
|
||||
* removeds a gpr device, mapped to a Audio packet device.
|
||||
*/
|
||||
static int audio_pkt_remove(struct gpr_device *adev)
|
||||
{
|
||||
if(ap_priv)
|
||||
{
|
||||
mutex_lock(&ap_priv->lock);
|
||||
ap_priv->adev = NULL;
|
||||
ap_priv->status = AUDIO_PKT_REMOVED;
|
||||
mutex_unlock(&ap_priv->lock);
|
||||
dev_dbg(&adev->dev, "%s: Driver[%s] Removing\n",
|
||||
__func__, adev->name);
|
||||
dev_set_drvdata(&adev->dev, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
dev_err(&adev->dev, "%s: Driver[%s] Remove Failed\n",
|
||||
__func__, adev->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id audio_pkt_match_table[] = {
|
||||
{ .compatible = "qcom,audio-pkt" },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, audio_pkt_match_table);
|
||||
|
||||
static struct gpr_driver audio_pkt_driver = {
|
||||
.probe = audio_pkt_probe,
|
||||
.remove = audio_pkt_remove,
|
||||
.callback = audio_pkt_srvc_callback,
|
||||
.driver = {
|
||||
.name = MODULE_NAME,
|
||||
.of_match_table = of_match_ptr(audio_pkt_match_table),
|
||||
},
|
||||
};
|
||||
|
||||
static int audio_pkt_plaform_driver_register_gpr(struct platform_device *pdev,
|
||||
struct audio_pkt_device *audpkt_dev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ap_priv = devm_kzalloc(&pdev->dev,
|
||||
sizeof(*ap_priv), GFP_KERNEL);
|
||||
if (!ap_priv)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = gpr_driver_register(&audio_pkt_driver);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "%s: registering to gpr driver failed, err = %d\n",
|
||||
__func__, ret);
|
||||
goto err;
|
||||
}
|
||||
|
||||
mutex_init(&ap_priv->lock);
|
||||
ap_priv->status = AUDIO_PKT_INIT;
|
||||
ap_priv->ap_dev = audpkt_dev;
|
||||
ap_priv->dev = audpkt_dev->dev;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_platform_driver_probe() - Probe a AUDIO packet device
|
||||
*
|
||||
* adev: Pointer to platform device.
|
||||
*
|
||||
* return: 0 on success, standard Linux error codes on error.
|
||||
*
|
||||
* This function is called when the underlying device tree driver registers
|
||||
* a platform device, mapped to a Audio packet device.
|
||||
*/
|
||||
static int audio_pkt_platform_driver_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
struct audio_pkt_device *audpkt_dev;
|
||||
|
||||
audpkt_dev = devm_kzalloc(&pdev->dev, sizeof(*audpkt_dev), GFP_KERNEL);
|
||||
if (!audpkt_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = alloc_chrdev_region(&audpkt_dev->audio_pkt_major, 0,
|
||||
MINOR_NUMBER_COUNT,AUDPKT_DRIVER_NAME);
|
||||
if (ret < 0) {
|
||||
AUDIO_PKT_ERR("alloc_chrdev_region failed ret:%d\n", ret);
|
||||
goto err_chrdev;
|
||||
}
|
||||
|
||||
audpkt_dev->audio_pkt_class = class_create(THIS_MODULE,
|
||||
AUDPKT_DRIVER_NAME);
|
||||
if (IS_ERR(audpkt_dev->audio_pkt_class)) {
|
||||
ret = PTR_ERR(audpkt_dev->audio_pkt_class);
|
||||
AUDIO_PKT_ERR("class_create failed ret:%ld\n",
|
||||
PTR_ERR(audpkt_dev->audio_pkt_class));
|
||||
goto err_class;
|
||||
}
|
||||
|
||||
audpkt_dev->dev = device_create(audpkt_dev->audio_pkt_class, NULL,
|
||||
audpkt_dev->audio_pkt_major, NULL,
|
||||
AUDPKT_DRIVER_NAME);
|
||||
if (IS_ERR(audpkt_dev->dev)) {
|
||||
ret = PTR_ERR(audpkt_dev->dev);
|
||||
AUDIO_PKT_ERR("device_create failed ret:%ld\n",
|
||||
PTR_ERR(audpkt_dev->dev));
|
||||
goto err_device;
|
||||
}
|
||||
strlcpy(audpkt_dev->dev_name, AUDPKT_DRIVER_NAME, 20);
|
||||
strlcpy(audpkt_dev->ch_name, CHANNEL_NAME, 20);
|
||||
dev_set_name(audpkt_dev->dev, audpkt_dev->dev_name);
|
||||
|
||||
mutex_init(&audpkt_dev->lock);
|
||||
|
||||
spin_lock_init(&audpkt_dev->queue_lock);
|
||||
skb_queue_head_init(&audpkt_dev->queue);
|
||||
init_waitqueue_head(&audpkt_dev->readq);
|
||||
|
||||
cdev_init(&audpkt_dev->cdev, &audio_pkt_fops);
|
||||
audpkt_dev->cdev.owner = THIS_MODULE;
|
||||
|
||||
ret = cdev_add(&audpkt_dev->cdev, audpkt_dev->audio_pkt_major,
|
||||
MINOR_NUMBER_COUNT);
|
||||
if (ret) {
|
||||
AUDIO_PKT_ERR("cdev_add failed for %s ret:%d\n",
|
||||
audpkt_dev->dev_name, ret);
|
||||
goto free_dev;
|
||||
}
|
||||
|
||||
ret = audio_pkt_plaform_driver_register_gpr(pdev, audpkt_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "%s: Failed to register with gpr, err = %d\n",
|
||||
__func__, ret);
|
||||
goto free_dev;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, ap_priv);
|
||||
AUDIO_PKT_INFO("Audio Packet Port Driver Initialized\n");
|
||||
|
||||
goto done;
|
||||
//return of_platform_populate(dev->of_node, NULL, NULL, dev);
|
||||
|
||||
free_dev:
|
||||
device_destroy(audpkt_dev->audio_pkt_class,audpkt_dev->audio_pkt_major);
|
||||
err_device:
|
||||
class_destroy(audpkt_dev->audio_pkt_class);
|
||||
err_class:
|
||||
unregister_chrdev_region(MAJOR(audpkt_dev->audio_pkt_major),
|
||||
MINOR_NUMBER_COUNT);
|
||||
err_chrdev:
|
||||
done:
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_pkt_platform_driver_remove() - Remove a AUDIO packet platform device
|
||||
*
|
||||
* adev: Pointer to platform device.
|
||||
*
|
||||
* return: 0 on success, standard Linux error codes on error.
|
||||
*
|
||||
* This function is called when the underlying device tree driver
|
||||
* removes a platform device, mapped to a Audio packet device.
|
||||
*/
|
||||
static int audio_pkt_platform_driver_remove(struct platform_device *adev)
|
||||
{
|
||||
struct audio_pkt_priv *ap_priv = platform_get_drvdata(adev);
|
||||
struct audio_pkt_device *audpkt_dev = ap_priv->ap_dev;
|
||||
|
||||
gpr_driver_unregister(&audio_pkt_driver);
|
||||
|
||||
audio_pkt_internal_release(adev);
|
||||
|
||||
if (audpkt_dev) {
|
||||
cdev_del(&audpkt_dev->cdev);
|
||||
device_destroy(audpkt_dev->audio_pkt_class,audpkt_dev->audio_pkt_major);
|
||||
class_destroy(audpkt_dev->audio_pkt_class);
|
||||
unregister_chrdev_region(MAJOR(audpkt_dev->audio_pkt_major),
|
||||
MINOR_NUMBER_COUNT);
|
||||
}
|
||||
|
||||
//of_platform_depopulate(&adev->dev);
|
||||
AUDIO_PKT_INFO("Audio Packet Port Driver Removed\n");
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static const struct of_device_id audio_pkt_platform_match_table[] = {
|
||||
{ .compatible = "qcom,audio-pkt-core-platform"},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, audio_pkt_platform_match_table);
|
||||
|
||||
|
||||
static struct platform_driver audio_pkt_core_platform_driver = {
|
||||
.probe = audio_pkt_platform_driver_probe,
|
||||
.remove = audio_pkt_platform_driver_remove,
|
||||
.driver = {
|
||||
.name = MODULE_NAME,
|
||||
.of_match_table = of_match_ptr(audio_pkt_platform_match_table),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
static int __init audio_pkt_init(void)
|
||||
{
|
||||
return platform_driver_register(&audio_pkt_core_platform_driver);
|
||||
}
|
||||
|
||||
static void __exit audio_pkt_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&audio_pkt_core_platform_driver);
|
||||
}
|
||||
module_init(audio_pkt_init);
|
||||
module_exit(audio_pkt_exit);
|
||||
|
||||
MODULE_DESCRIPTION("MSM Audio Packet Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
661
qcom/opensource/audio-kernel/ipc/gpr-lite.c
Normal file
661
qcom/opensource/audio-kernel/ipc/gpr-lite.c
Normal file
@@ -0,0 +1,661 @@
|
||||
/* Copyright (c) 2011-2017, 2019-2021 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2018, Linaro Limited
|
||||
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. 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 <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <ipc/gpr-lite.h>
|
||||
#include <linux/rpmsg.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
#include <soc/snd_event.h>
|
||||
#include <dsp/audio_notifier.h>
|
||||
|
||||
#define APM_EVENT_MODULE_TO_CLIENT 0x03001000
|
||||
#define WAKELOCK_TIMEOUT 200
|
||||
|
||||
struct gpr {
|
||||
struct rpmsg_endpoint *ch;
|
||||
struct device *dev;
|
||||
spinlock_t gpr_lock;
|
||||
bool is_initial_boot;
|
||||
|
||||
spinlock_t svcs_lock;
|
||||
struct idr svcs_idr;
|
||||
int dest_domain_id;
|
||||
struct work_struct notifier_reg_work;
|
||||
struct wakeup_source *wsource;
|
||||
};
|
||||
|
||||
static struct gpr_q6 q6;
|
||||
static struct gpr *gpr_priv;
|
||||
|
||||
enum gpr_subsys_state gpr_get_q6_state(void)
|
||||
{
|
||||
return atomic_read(&q6.q6_state);
|
||||
}
|
||||
EXPORT_SYMBOL(gpr_get_q6_state);
|
||||
|
||||
enum gpr_subsys_state gpr_get_modem_state(void)
|
||||
{
|
||||
return atomic_read(&q6.modem_state);
|
||||
}
|
||||
EXPORT_SYMBOL(gpr_get_modem_state);
|
||||
|
||||
|
||||
void gpr_subsys_notif_register(char *client_name, int domain,
|
||||
struct notifier_block *nb)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = audio_notifier_register(client_name, domain, nb);
|
||||
if (ret < 0)
|
||||
dev_err_ratelimited(gpr_priv->dev, "%s: Audio notifier register failed for domain %d ret = %d\n",
|
||||
__func__, domain, ret);
|
||||
}
|
||||
|
||||
void gpr_subsys_notif_deregister(char *client_name)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = audio_notifier_deregister(client_name);
|
||||
if (ret < 0)
|
||||
dev_err_ratelimited(gpr_priv->dev, "%s: Audio notifier de-register failed for client %s\n",
|
||||
__func__, client_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* gpr_send_pkt() - Send a gpr message from gpr device
|
||||
*
|
||||
* @adev: Pointer to previously registered gpr device.
|
||||
* @pkt: Pointer to gpr packet to send
|
||||
*
|
||||
* Return: Will be an negative and/or packet size on success.
|
||||
*/
|
||||
int gpr_send_pkt(struct gpr_device *adev, struct gpr_pkt *pkt)
|
||||
{
|
||||
struct gpr *gpr;
|
||||
struct gpr_hdr *hdr;
|
||||
unsigned long flags;
|
||||
uint32_t pkt_size;
|
||||
int ret;
|
||||
|
||||
if (gpr_get_q6_state() == GPR_SUBSYS_DOWN) {
|
||||
pr_err_ratelimited("%s: q6 state is down\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if(!adev)
|
||||
{
|
||||
pr_err_ratelimited("%s: enter pointer adev[%pK] \n", __func__, adev);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if(!(adev->dev.parent))
|
||||
{
|
||||
pr_err_ratelimited("%s: enter pointer adev->dev.parent[%pK] \n",
|
||||
__func__, adev->dev.parent);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
gpr = dev_get_drvdata(adev->dev.parent);
|
||||
|
||||
if (!gpr) {
|
||||
pr_err_ratelimited("%s: Failed to get gpr dev pointer : gpr[%pK] \n",
|
||||
__func__, gpr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((adev->domain_id == GPR_DOMAIN_ADSP) &&
|
||||
(gpr_get_q6_state() != GPR_SUBSYS_LOADED)) {
|
||||
dev_err_ratelimited(gpr->dev, "%s: Still Dsp is not Up\n", __func__);
|
||||
return -ENETRESET;
|
||||
} else if ((adev->domain_id == GPR_DOMAIN_MODEM) &&
|
||||
(gpr_get_modem_state() == GPR_SUBSYS_DOWN)) {
|
||||
dev_err_ratelimited(gpr->dev, "%s: Still Modem is not Up\n", __func__);
|
||||
return -ENETRESET;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&adev->lock, flags);
|
||||
|
||||
hdr = &pkt->hdr;
|
||||
hdr->dst_domain_id = adev->domain_id;
|
||||
pkt_size = GPR_PKT_GET_PACKET_BYTE_SIZE(hdr->header);
|
||||
|
||||
dev_dbg(gpr->dev, "SVC_ID %d %s packet size %d\n",
|
||||
adev->svc_id, __func__, pkt_size);
|
||||
ret = rpmsg_trysend(gpr->ch, pkt, pkt_size);
|
||||
spin_unlock_irqrestore(&adev->lock, flags);
|
||||
|
||||
return ret ? ret : pkt_size;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpr_send_pkt);
|
||||
|
||||
/**
|
||||
* apr_set_modem_state - Update modem load status.
|
||||
*
|
||||
* @state: State to update modem load status
|
||||
*
|
||||
*/
|
||||
void gpr_set_modem_state(enum gpr_subsys_state state)
|
||||
{
|
||||
atomic_set(&q6.modem_state, state);
|
||||
}
|
||||
EXPORT_SYMBOL(gpr_set_modem_state);
|
||||
|
||||
|
||||
static void gpr_modem_down(unsigned long opcode)
|
||||
{
|
||||
gpr_set_modem_state(GPR_SUBSYS_DOWN);
|
||||
//dispatch_event(opcode, APR_DEST_MODEM);
|
||||
}
|
||||
|
||||
static void gpr_modem_up(void)
|
||||
{
|
||||
//if (apr_cmpxchg_modem_state(APR_SUBSYS_DOWN, APR_SUBSYS_UP) ==
|
||||
// APR_SUBSYS_DOWN)
|
||||
// wake_up(&modem_wait);
|
||||
//is_modem_up = 1;
|
||||
}
|
||||
|
||||
|
||||
int gpr_set_q6_state(enum gpr_subsys_state state)
|
||||
{
|
||||
dev_dbg(gpr_priv->dev,"%s: setting adsp state %d\n", __func__, state);
|
||||
if (state < GPR_SUBSYS_DOWN || state > GPR_SUBSYS_LOADED)
|
||||
return -EINVAL;
|
||||
atomic_set(&q6.q6_state, state);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(gpr_set_q6_state);
|
||||
|
||||
static void gpr_ssr_disable(struct device *dev, void *data)
|
||||
{
|
||||
gpr_set_q6_state(GPR_SUBSYS_DOWN);
|
||||
}
|
||||
|
||||
static const struct snd_event_ops gpr_ssr_ops = {
|
||||
.disable = gpr_ssr_disable,
|
||||
};
|
||||
|
||||
static void gpr_adsp_down(unsigned long opcode)
|
||||
{
|
||||
dev_info_ratelimited(gpr_priv->dev, "%s: Q6 is Down\n", __func__);
|
||||
gpr_set_q6_state(GPR_SUBSYS_DOWN);
|
||||
snd_event_notify(gpr_priv->dev, SND_EVENT_DOWN);
|
||||
}
|
||||
|
||||
static void gpr_adsp_up(void)
|
||||
{
|
||||
dev_info_ratelimited(gpr_priv->dev, "%s: Q6 is Up\n", __func__);
|
||||
gpr_set_q6_state(GPR_SUBSYS_LOADED);
|
||||
snd_event_notify(gpr_priv->dev, SND_EVENT_UP);
|
||||
}
|
||||
|
||||
static int gpr_notifier_service_cb(struct notifier_block *this,
|
||||
unsigned long opcode, void *data)
|
||||
{
|
||||
struct audio_notifier_cb_data *cb_data = data;
|
||||
|
||||
if (cb_data == NULL) {
|
||||
dev_err_ratelimited(gpr_priv->dev, "%s: Callback data is NULL!\n", __func__);
|
||||
goto done;
|
||||
}
|
||||
|
||||
dev_dbg(gpr_priv->dev,"%s: Service opcode 0x%lx, domain %d\n",
|
||||
__func__, opcode, cb_data->domain);
|
||||
|
||||
switch (opcode) {
|
||||
case AUDIO_NOTIFIER_SERVICE_DOWN:
|
||||
/*
|
||||
* Use flag to ignore down notifications during
|
||||
* initial boot. There is no benefit from error
|
||||
* recovery notifications during initial boot
|
||||
* up since everything is expected to be down.
|
||||
*/
|
||||
spin_lock(&gpr_priv->gpr_lock);
|
||||
if (gpr_priv->is_initial_boot) {
|
||||
spin_unlock(&gpr_priv->gpr_lock);
|
||||
break;
|
||||
}
|
||||
spin_unlock(&gpr_priv->gpr_lock);
|
||||
if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
|
||||
gpr_modem_down(opcode);
|
||||
else
|
||||
gpr_adsp_down(opcode);
|
||||
break;
|
||||
case AUDIO_NOTIFIER_SERVICE_UP:
|
||||
if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
|
||||
gpr_modem_up();
|
||||
else
|
||||
gpr_adsp_up();
|
||||
spin_lock(&gpr_priv->gpr_lock);
|
||||
gpr_priv->is_initial_boot = false;
|
||||
spin_unlock(&gpr_priv->gpr_lock);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
done:
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
static struct notifier_block adsp_service_nb = {
|
||||
.notifier_call = gpr_notifier_service_cb,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static struct notifier_block modem_service_nb = {
|
||||
.notifier_call = gpr_notifier_service_cb,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
|
||||
static void gpr_dev_release(struct device *dev)
|
||||
{
|
||||
struct gpr_device *adev = to_gpr_device(dev);
|
||||
|
||||
kfree(adev);
|
||||
}
|
||||
|
||||
static int gpr_callback(struct rpmsg_device *rpdev, void *buf,
|
||||
int len, void *priv, u32 addr)
|
||||
{
|
||||
struct gpr *gpr = dev_get_drvdata(&rpdev->dev);
|
||||
uint16_t hdr_size, pkt_size, svc_id;
|
||||
//uint16_t ver;
|
||||
struct gpr_device *svc = NULL;
|
||||
struct gpr_driver *adrv = NULL;
|
||||
struct gpr_hdr *hdr;
|
||||
unsigned long flags;
|
||||
//uint32_t opcode_type;
|
||||
|
||||
if (len <= GPR_HDR_SIZE) {
|
||||
dev_err_ratelimited(gpr->dev, "GPR: Improper gpr pkt received:%p %d\n",
|
||||
buf, len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hdr = buf;
|
||||
|
||||
hdr_size = GPR_PKT_GET_HEADER_BYTE_SIZE(hdr->header);
|
||||
if (hdr_size < GPR_HDR_SIZE) {
|
||||
dev_err_ratelimited(gpr->dev, "GPR: Wrong hdr size:%d\n", hdr_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pkt_size = GPR_PKT_GET_PACKET_BYTE_SIZE(hdr->header);
|
||||
dev_dbg(gpr->dev,"Header %x", hdr->header);
|
||||
|
||||
if (pkt_size < GPR_HDR_SIZE || pkt_size != len) {
|
||||
dev_err_ratelimited(gpr->dev, "GPR: Wrong packet size\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(gpr->dev, "%s: dst_port %x hdr_size %d pkt_size %d\n",
|
||||
__func__ , hdr->dst_port, hdr_size, pkt_size);
|
||||
|
||||
if (hdr->opcode == APM_EVENT_MODULE_TO_CLIENT) {
|
||||
dev_err(gpr->dev, "%s: Acquire wakelock in case of module event with timeout %d",
|
||||
__func__, WAKELOCK_TIMEOUT);
|
||||
pm_wakeup_ws_event(gpr_priv->wsource, WAKELOCK_TIMEOUT, true);
|
||||
}
|
||||
svc_id = hdr->dst_port;
|
||||
spin_lock_irqsave(&gpr->svcs_lock, flags);
|
||||
svc = idr_find(&gpr->svcs_idr, svc_id);
|
||||
if (svc && svc->dev.driver) {
|
||||
adrv = to_gpr_driver(svc->dev.driver);
|
||||
} else {
|
||||
/*Does not match any SVC ID hence would be routed to audio passthrough*/
|
||||
svc = idr_find(&gpr->svcs_idr, GPR_SVC_MAX);
|
||||
if (svc && svc->dev.driver)
|
||||
adrv = to_gpr_driver(svc->dev.driver);
|
||||
}
|
||||
spin_unlock_irqrestore(&gpr->svcs_lock, flags);
|
||||
|
||||
if (!adrv) {
|
||||
dev_err_ratelimited(gpr->dev, "GPR: service is not registered\n");
|
||||
if (hdr->opcode == APM_EVENT_MODULE_TO_CLIENT)
|
||||
__pm_relax(gpr_priv->wsource);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: hdr_size is not same as GPR_HDR_SIZE as remote can include
|
||||
* optional headers in to gpr_hdr which should be ignored
|
||||
*/
|
||||
|
||||
adrv->callback(svc, buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpr_device_match(struct device *dev, struct device_driver *drv)
|
||||
{
|
||||
struct gpr_device *adev = to_gpr_device(dev);
|
||||
struct gpr_driver *adrv = to_gpr_driver(drv);
|
||||
const struct gpr_device_id *id = adrv->id_table;
|
||||
|
||||
/* Attempt an OF style match first */
|
||||
if (of_driver_match_device(dev, drv))
|
||||
return 1;
|
||||
|
||||
if (!id)
|
||||
return 0;
|
||||
|
||||
while (id->domain_id != 0 || id->svc_id != 0) {
|
||||
if (id->domain_id == adev->domain_id &&
|
||||
id->svc_id == adev->svc_id)
|
||||
return 1;
|
||||
id++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpr_device_probe(struct device *dev)
|
||||
{
|
||||
struct gpr_device *adev = to_gpr_device(dev);
|
||||
struct gpr_driver *adrv = to_gpr_driver(dev->driver);
|
||||
|
||||
return adrv->probe(adev);
|
||||
}
|
||||
|
||||
static void gpr_device_remove(struct device *dev)
|
||||
{
|
||||
struct gpr_device *adev = to_gpr_device(dev);
|
||||
struct gpr_driver *adrv;
|
||||
struct gpr *gpr = dev_get_drvdata(adev->dev.parent);
|
||||
unsigned long flags;
|
||||
|
||||
if (dev->driver) {
|
||||
adrv = to_gpr_driver(dev->driver);
|
||||
if (adrv->remove)
|
||||
adrv->remove(adev);
|
||||
spin_lock_irqsave(&gpr->svcs_lock, flags);
|
||||
idr_remove(&gpr->svcs_idr, adev->svc_id);
|
||||
spin_unlock_irqrestore(&gpr->svcs_lock, flags);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int gpr_uevent(struct device *dev, struct kobj_uevent_env *env)
|
||||
{
|
||||
struct gpr_device *adev = to_gpr_device(dev);
|
||||
int ret;
|
||||
|
||||
ret = of_device_uevent_modalias(dev, env);
|
||||
if (ret != -ENODEV)
|
||||
return ret;
|
||||
|
||||
return add_uevent_var(env, "MODALIAS=gpr:%s", adev->name);
|
||||
}
|
||||
|
||||
struct bus_type gprbus = {
|
||||
.name = "gprbus",
|
||||
.match = gpr_device_match,
|
||||
.probe = gpr_device_probe,
|
||||
.uevent = gpr_uevent,
|
||||
.remove = gpr_device_remove,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(gprbus);
|
||||
|
||||
static int gpr_add_device(struct device *dev, struct device_node *np,
|
||||
const struct gpr_device_id *id)
|
||||
{
|
||||
struct gpr *gpr = dev_get_drvdata(dev);
|
||||
struct gpr_device *adev = NULL;
|
||||
int ret;
|
||||
unsigned long flags;
|
||||
|
||||
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
|
||||
if (!adev)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&adev->lock);
|
||||
|
||||
adev->svc_id = id->svc_id;
|
||||
adev->domain_id = id->domain_id;
|
||||
adev->version = id->svc_version;
|
||||
if (np)
|
||||
strscpy(adev->name, np->name, GPR_NAME_SIZE);
|
||||
else
|
||||
strscpy(adev->name, id->name, GPR_NAME_SIZE);
|
||||
|
||||
dev_set_name(&adev->dev, "gprsvc:%s:%x:%x", adev->name,
|
||||
id->domain_id, id->svc_id);
|
||||
|
||||
adev->dev.bus = &gprbus;
|
||||
adev->dev.parent = dev;
|
||||
adev->dev.of_node = np;
|
||||
adev->dev.release = gpr_dev_release;
|
||||
adev->dev.driver = NULL;
|
||||
|
||||
spin_lock_irqsave(&gpr->svcs_lock, flags);
|
||||
idr_alloc(&gpr->svcs_idr, adev, id->svc_id,
|
||||
id->svc_id + 1, GFP_ATOMIC);
|
||||
spin_unlock_irqrestore(&gpr->svcs_lock, flags);
|
||||
|
||||
dev_info_ratelimited(dev, "Adding GPR dev: %s\n", dev_name(&adev->dev));
|
||||
|
||||
ret = device_register(&adev->dev);
|
||||
if (ret) {
|
||||
dev_err_ratelimited(dev, "device_register failed: %d\n", ret);
|
||||
put_device(&adev->dev);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void of_register_gpr_devices(struct device *dev)
|
||||
{
|
||||
struct gpr *gpr = dev_get_drvdata(dev);
|
||||
struct device_node *node;
|
||||
|
||||
for_each_child_of_node(dev->of_node, node) {
|
||||
struct gpr_device_id id = { {0} };
|
||||
|
||||
if (of_property_read_u32(node, "reg", &id.svc_id))
|
||||
continue;
|
||||
|
||||
id.domain_id = gpr->dest_domain_id;
|
||||
|
||||
if (gpr_add_device(dev, node, &id))
|
||||
dev_err_ratelimited(dev, "Failed to add gpr %d svc\n", id.svc_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void gpr_notifier_register(struct work_struct *work)
|
||||
{
|
||||
if (GPR_DOMAIN_ADSP == gpr_priv->dest_domain_id) {
|
||||
gpr_subsys_notif_register("gpr_adsp",
|
||||
AUDIO_NOTIFIER_ADSP_DOMAIN,
|
||||
&adsp_service_nb);
|
||||
} else if (GPR_DOMAIN_MODEM == gpr_priv->dest_domain_id) {
|
||||
gpr_subsys_notif_register("gpr_modem",
|
||||
AUDIO_NOTIFIER_MODEM_DOMAIN,
|
||||
&modem_service_nb);
|
||||
}
|
||||
|
||||
dev_info_ratelimited(gpr_priv->dev,
|
||||
"%s: registered via subsys_notif_register for domain id(%d)",
|
||||
__func__, gpr_priv->dest_domain_id );
|
||||
return;
|
||||
}
|
||||
|
||||
static int gpr_probe(struct rpmsg_device *rpdev)
|
||||
{
|
||||
struct device *dev = &rpdev->dev;
|
||||
int ret;
|
||||
|
||||
if (!audio_notifier_probe_status()) {
|
||||
pr_err("%s: Audio notify probe not completed, defer audio gpr probe\n",
|
||||
__func__);
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
||||
gpr_priv = devm_kzalloc(dev, sizeof(*gpr_priv), GFP_KERNEL);
|
||||
if (!gpr_priv)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock_init(&gpr_priv->gpr_lock);
|
||||
mutex_init(&q6.lock);
|
||||
|
||||
spin_lock(&gpr_priv->gpr_lock);
|
||||
gpr_priv->is_initial_boot = true;
|
||||
spin_unlock(&gpr_priv->gpr_lock);
|
||||
|
||||
dev_set_drvdata(dev, gpr_priv);
|
||||
gpr_priv->ch = rpdev->ept;
|
||||
gpr_priv->dev = dev;
|
||||
spin_lock_init(&gpr_priv->svcs_lock);
|
||||
idr_init(&gpr_priv->svcs_idr);
|
||||
|
||||
ret = snd_event_client_register(&rpdev->dev, &gpr_ssr_ops, NULL);
|
||||
if (ret) {
|
||||
dev_err(dev,"%s: Registration with SND event fwk failed ret = %d\n",
|
||||
__func__, ret);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(dev->of_node, "reg", &gpr_priv->dest_domain_id);
|
||||
if (ret) {
|
||||
dev_err(dev, "GPR Domain ID not specified in DT\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
of_register_gpr_devices(dev);
|
||||
|
||||
INIT_WORK(&gpr_priv->notifier_reg_work, gpr_notifier_register);
|
||||
|
||||
if (GPR_DOMAIN_ADSP == gpr_priv->dest_domain_id ||
|
||||
GPR_DOMAIN_MODEM == gpr_priv->dest_domain_id) {
|
||||
schedule_work(&gpr_priv->notifier_reg_work);
|
||||
} else {
|
||||
dev_err(dev, "%s: invalid dest_domain_id %s\n", __func__,
|
||||
gpr_priv->dest_domain_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
gpr_priv->wsource = wakeup_source_register(gpr_priv->dev, "audio-gpr");
|
||||
dev_info(dev, "%s: gpr-lite probe success\n",
|
||||
__func__);
|
||||
|
||||
#ifndef CONFIG_MSM_QDSP6_PDR
|
||||
gpr_set_q6_state(GPR_SUBSYS_LOADED);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpr_remove_device(struct device *dev, void *null)
|
||||
{
|
||||
struct gpr_device *adev = to_gpr_device(dev);
|
||||
device_unregister(&adev->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gpr_remove(struct rpmsg_device *rpdev)
|
||||
{
|
||||
struct device *dev = &rpdev->dev;
|
||||
|
||||
wakeup_source_unregister(gpr_priv->wsource);
|
||||
snd_event_client_deregister(&rpdev->dev);
|
||||
dev_info(dev, "%s: deregistering via subsys_notif_register for domain_id(%d)",
|
||||
__func__, gpr_priv->dest_domain_id );
|
||||
if (GPR_DOMAIN_ADSP == gpr_priv->dest_domain_id)
|
||||
{
|
||||
gpr_subsys_notif_deregister("gpr_adsp");
|
||||
}
|
||||
else if(GPR_DOMAIN_MODEM == gpr_priv->dest_domain_id)
|
||||
{
|
||||
gpr_subsys_notif_deregister("gpr_modem");
|
||||
}
|
||||
device_for_each_child(&rpdev->dev, NULL, gpr_remove_device);
|
||||
}
|
||||
|
||||
/*
|
||||
* __gpr_driver_register() - Client driver registration with gprbus
|
||||
*
|
||||
* @drv:Client driver to be associated with client-device.
|
||||
* @owner: owning module/driver
|
||||
*
|
||||
* This API will register the client driver with the gprbus
|
||||
* It is called from the driver's module-init function.
|
||||
*/
|
||||
int __gpr_driver_register(struct gpr_driver *drv, struct module *owner)
|
||||
{
|
||||
drv->driver.bus = &gprbus;
|
||||
drv->driver.owner = owner;
|
||||
|
||||
return driver_register(&drv->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__gpr_driver_register);
|
||||
|
||||
/*
|
||||
* gpr_driver_unregister() - Undo effect of gpr_driver_register
|
||||
*
|
||||
* @drv: Client driver to be unregistered
|
||||
*/
|
||||
void gpr_driver_unregister(struct gpr_driver *drv)
|
||||
{
|
||||
driver_unregister(&drv->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpr_driver_unregister);
|
||||
|
||||
static const struct of_device_id gpr_of_match[] = {
|
||||
{ .compatible = "qcom,gpr"},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, gpr_of_match);
|
||||
|
||||
static struct rpmsg_driver gpr_driver = {
|
||||
.probe = gpr_probe,
|
||||
.remove = gpr_remove,
|
||||
.callback = gpr_callback,
|
||||
.drv = {
|
||||
.name = "qcom,gpr",
|
||||
.of_match_table = gpr_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init gpr_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = bus_register(&gprbus);
|
||||
if (!ret)
|
||||
ret = register_rpmsg_driver(&gpr_driver);
|
||||
else
|
||||
bus_unregister(&gprbus);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit gpr_exit(void)
|
||||
{
|
||||
bus_unregister(&gprbus);
|
||||
unregister_rpmsg_driver(&gpr_driver);
|
||||
}
|
||||
|
||||
subsys_initcall(gpr_init);
|
||||
module_exit(gpr_exit);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_DESCRIPTION("QTI GPR Bus");
|
Reference in New Issue
Block a user