asoc: codecs: codec driver support for ep92 HDMI bridge

Codec driver to support Explore EP92A6 HDMI bridge chip.

Change-Id: I18132ee465180703a018a4e3c1f3d6418253410c
Signed-off-by: Ralf Herz <rherz@codeaurora.org>
This commit is contained in:
Ralf Herz 2018-06-21 18:50:09 +02:00
parent 1fdb5b3e3f
commit 5f30251f7e
5 changed files with 1741 additions and 0 deletions

View file

@ -42,6 +42,7 @@ endif
ifeq ($(TARGET_SUPPORT), $(filter $(TARGET_SUPPORT), qcs40x))
obj-m += asoc/codecs/bolero/
obj-m += asoc/codecs/csra66x0/
obj-m += asoc/codecs/ep92/
endif
all:

View file

@ -0,0 +1,50 @@
# Android makefile for audio kernel modules
# Assume no targets will be supported
# Check if this driver needs be built for current target
ifeq ($(call is-board-platform,qcs405),true)
AUDIO_SELECT := CONFIG_SND_SOC_QCS405=m
endif
AUDIO_CHIPSET := audio
# Build/Package only in case of supported target
ifeq ($(call is-board-platform-in-list,qcs405),true)
LOCAL_PATH := $(call my-dir)
# This makefile is only for DLKM
ifneq ($(findstring vendor,$(LOCAL_PATH)),)
ifneq ($(findstring opensource,$(LOCAL_PATH)),)
AUDIO_BLD_DIR := $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/audio-kernel
endif # opensource
DLKM_DIR := $(TOP)/device/qcom/common/dlkm
# Build audio.ko as $(AUDIO_CHIPSET)_audio.ko
###########################################################
# This is set once per LOCAL_PATH, not per (kernel) module
KBUILD_OPTIONS := AUDIO_ROOT=$(AUDIO_BLD_DIR)
# We are actually building audio.ko here, as per the
# requirement we are specifying <chipset>_audio.ko as LOCAL_MODULE.
# This means we need to rename the module to <chipset>_audio.ko
# after audio.ko is built.
KBUILD_OPTIONS += MODNAME=ep92_dlkm
KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
KBUILD_OPTIONS += $(AUDIO_SELECT)
###########################################################
include $(CLEAR_VARS)
LOCAL_MODULE := $(AUDIO_CHIPSET)_ep92.ko
LOCAL_MODULE_KBUILD_NAME := ep92_dlkm.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_DEBUG_ENABLE := true
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
include $(DLKM_DIR)/AndroidKernelModule.mk
###########################################################
###########################################################
endif # DLKM check
endif # supported target check

106
asoc/codecs/ep92/Kbuild Normal file
View file

@ -0,0 +1,106 @@
# 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
ifeq ($(KERNEL_BUILD), 1)
# These are configurable via Kconfig for kernel-based builds
# Need to explicitly configure for Android-based builds
AUDIO_BLD_DIR := $(ANDROID_BUILD_TOP)/kernel/msm-4.14
AUDIO_ROOT := $(AUDIO_BLD_DIR)/techpack/audio
endif
ifeq ($(KERNEL_BUILD), 0)
ifeq ($(CONFIG_ARCH_QCS405), y)
include $(AUDIO_ROOT)/config/qcs405auto.conf
export
INCS += -include $(AUDIO_ROOT)/config/qcs405autoconf.h
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
UAPI_INC := -I$(AUDIO_ROOT)/include/$(UAPI_DIR)
############ COMMON ############
COMMON_DIR := include
COMMON_INC := -I$(AUDIO_ROOT)/$(COMMON_DIR)
############ EP92 ############
# for EP92 Codec
ifdef CONFIG_SND_SOC_EP92
EP92_OBJS += ep92.o
endif
LINUX_INC += -Iinclude/linux
INCS += $(COMMON_INC) \
$(UAPI_INC)
#EXTRA_CFLAGS += $(INCS)
ccflags-y += $(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
ccflags-y += -Wmaybe-uninitialized
endif
#EXTRA_CFLAGS += -Wmissing-prototypes
ifeq ($(call cc-option-yn, -Wheader-guard),y)
#EXTRA_CFLAGS += -Wheader-guard
ccflags-y += -Wheader-guard
endif
ifeq ($(KERNEL_BUILD), 0)
KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/ipc/Module.symvers
KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/dsp/Module.symvers
KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/Module.symvers
KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/Module.symvers
KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/soc/Module.symvers
endif
# Module information used by KBuild framework
obj-$(CONFIG_SND_SOC_EP92) += ep92_dlkm.o
ep92_dlkm-y := $(EP92_OBJS)
# inject some build related information
DEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"

1382
asoc/codecs/ep92/ep92.c Normal file

File diff suppressed because it is too large Load diff

202
asoc/codecs/ep92/ep92.h Normal file
View file

@ -0,0 +1,202 @@
/*
* Copyright (c) 2018, 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 __EP92_H__
#define __EP92_H__
/* EP92 register addresses */
/* BI = Basic Info */
#define EP92_BI_VENDOR_ID_0 0x00
#define EP92_BI_VENDOR_ID_1 0x01
#define EP92_BI_DEVICE_ID_0 0x02
#define EP92_BI_DEVICE_ID_1 0x03
#define EP92_BI_VERSION_NUM 0x04
#define EP92_BI_VERSION_YEAR 0x05
#define EP92_BI_VERSION_MONTH 0x06
#define EP92_BI_VERSION_DATE 0x07
#define EP92_BI_GENERAL_INFO_0 0x08
#define EP92_BI_GENERAL_INFO_1 0x09
#define EP92_BI_GENERAL_INFO_2 0x0A
#define EP92_BI_GENERAL_INFO_3 0x0B
#define EP92_BI_GENERAL_INFO_4 0x0C
#define EP92_BI_GENERAL_INFO_5 0x0D
#define EP92_BI_GENERAL_INFO_6 0x0E
#define EP92_ISP_MODE_ENTER_ISP 0x0F
#define EP92_GENERAL_CONTROL_0 0x10
#define EP92_GENERAL_CONTROL_1 0x11
#define EP92_GENERAL_CONTROL_2 0x12
#define EP92_GENERAL_CONTROL_3 0x13
#define EP92_GENERAL_CONTROL_4 0x14
#define EP92_CEC_EVENT_CODE 0x15
#define EP92_CEC_EVENT_PARAM_1 0x16
#define EP92_CEC_EVENT_PARAM_2 0x17
#define EP92_CEC_EVENT_PARAM_3 0x18
#define EP92_CEC_EVENT_PARAM_4 0x19
/* RESERVED 0x1A */
/* ... ... */
/* RESERVED 0x1F */
#define EP92_AUDIO_INFO_SYSTEM_STATUS_0 0x20
#define EP92_AUDIO_INFO_SYSTEM_STATUS_1 0x21
#define EP92_AUDIO_INFO_AUDIO_STATUS 0x22
#define EP92_AUDIO_INFO_CHANNEL_STATUS_0 0x23
#define EP92_AUDIO_INFO_CHANNEL_STATUS_1 0x24
#define EP92_AUDIO_INFO_CHANNEL_STATUS_2 0x25
#define EP92_AUDIO_INFO_CHANNEL_STATUS_3 0x26
#define EP92_AUDIO_INFO_CHANNEL_STATUS_4 0x27
#define EP92_AUDIO_INFO_ADO_INFO_FRAME_0 0x28
#define EP92_AUDIO_INFO_ADO_INFO_FRAME_1 0x29
#define EP92_AUDIO_INFO_ADO_INFO_FRAME_2 0x2A
#define EP92_AUDIO_INFO_ADO_INFO_FRAME_3 0x2B
#define EP92_AUDIO_INFO_ADO_INFO_FRAME_4 0x2C
#define EP92_AUDIO_INFO_ADO_INFO_FRAME_5 0x2D
#define EP92_OTHER_PACKETS_HDMI_VS_0 0x2E
#define EP92_OTHER_PACKETS_HDMI_VS_1 0x2F
#define EP92_OTHER_PACKETS_ACP_PACKET 0x30
#define EP92_OTHER_PACKETS_AVI_INFO_FRAME_0 0x31
#define EP92_OTHER_PACKETS_AVI_INFO_FRAME_1 0x32
#define EP92_OTHER_PACKETS_AVI_INFO_FRAME_2 0x33
#define EP92_OTHER_PACKETS_AVI_INFO_FRAME_3 0x34
#define EP92_OTHER_PACKETS_AVI_INFO_FRAME_4 0x35
#define EP92_OTHER_PACKETS_GC_PACKET_0 0x36
#define EP92_OTHER_PACKETS_GC_PACKET_1 0x37
#define EP92_OTHER_PACKETS_GC_PACKET_2 0x38
#define EP92_MAX_REGISTER_ADDR EP92_OTHER_PACKETS_GC_PACKET_2
/* EP92 register default values */
static struct reg_default ep92_reg_defaults[] = {
{EP92_BI_VENDOR_ID_0, 0x17},
{EP92_BI_VENDOR_ID_1, 0x7A},
{EP92_BI_DEVICE_ID_0, 0x94},
{EP92_BI_DEVICE_ID_1, 0xA3},
{EP92_BI_VERSION_NUM, 0x10},
{EP92_BI_VERSION_YEAR, 0x09},
{EP92_BI_VERSION_MONTH, 0x07},
{EP92_BI_VERSION_DATE, 0x06},
{EP92_BI_GENERAL_INFO_0, 0x00},
{EP92_BI_GENERAL_INFO_1, 0x00},
{EP92_BI_GENERAL_INFO_2, 0x00},
{EP92_BI_GENERAL_INFO_3, 0x00},
{EP92_BI_GENERAL_INFO_4, 0x00},
{EP92_BI_GENERAL_INFO_5, 0x00},
{EP92_BI_GENERAL_INFO_6, 0x00},
{EP92_ISP_MODE_ENTER_ISP, 0x00},
{EP92_GENERAL_CONTROL_0, 0x20},
{EP92_GENERAL_CONTROL_1, 0x00},
{EP92_GENERAL_CONTROL_2, 0x00},
{EP92_GENERAL_CONTROL_3, 0x10},
{EP92_GENERAL_CONTROL_4, 0x00},
{EP92_CEC_EVENT_CODE, 0x00},
{EP92_CEC_EVENT_PARAM_1, 0x00},
{EP92_CEC_EVENT_PARAM_2, 0x00},
{EP92_CEC_EVENT_PARAM_3, 0x00},
{EP92_CEC_EVENT_PARAM_4, 0x00},
{EP92_AUDIO_INFO_SYSTEM_STATUS_0, 0x00},
{EP92_AUDIO_INFO_SYSTEM_STATUS_1, 0x00},
{EP92_AUDIO_INFO_AUDIO_STATUS, 0x00},
{EP92_AUDIO_INFO_CHANNEL_STATUS_0, 0x00},
{EP92_AUDIO_INFO_CHANNEL_STATUS_1, 0x00},
{EP92_AUDIO_INFO_CHANNEL_STATUS_2, 0x00},
{EP92_AUDIO_INFO_CHANNEL_STATUS_3, 0x00},
{EP92_AUDIO_INFO_CHANNEL_STATUS_4, 0x00},
{EP92_AUDIO_INFO_ADO_INFO_FRAME_0, 0x00},
{EP92_AUDIO_INFO_ADO_INFO_FRAME_1, 0x00},
{EP92_AUDIO_INFO_ADO_INFO_FRAME_2, 0x00},
{EP92_AUDIO_INFO_ADO_INFO_FRAME_3, 0x00},
{EP92_AUDIO_INFO_ADO_INFO_FRAME_4, 0x00},
{EP92_AUDIO_INFO_ADO_INFO_FRAME_5, 0x00},
{EP92_OTHER_PACKETS_HDMI_VS_0, 0x00},
{EP92_OTHER_PACKETS_HDMI_VS_1, 0x00},
{EP92_OTHER_PACKETS_ACP_PACKET, 0x00},
{EP92_OTHER_PACKETS_AVI_INFO_FRAME_0, 0x00},
{EP92_OTHER_PACKETS_AVI_INFO_FRAME_1, 0x00},
{EP92_OTHER_PACKETS_AVI_INFO_FRAME_2, 0x00},
{EP92_OTHER_PACKETS_AVI_INFO_FRAME_3, 0x00},
{EP92_OTHER_PACKETS_AVI_INFO_FRAME_4, 0x00},
{EP92_OTHER_PACKETS_GC_PACKET_0, 0x00},
{EP92_OTHER_PACKETS_GC_PACKET_1, 0x00},
{EP92_OTHER_PACKETS_GC_PACKET_2, 0x00},
};
/* shift/masks for register bits
* GI = General Info
* GC = General Control
* AI = Audio Info
*/
#define EP92_GI_ADO_CHF_MASK 0x01
#define EP92_GI_CEC_ECF_MASK 0x02
#define EP92_GC_POWER_SHIFT 7
#define EP92_GC_POWER_MASK 0x80
#define EP92_GC_AUDIO_PATH_SHIFT 5
#define EP92_GC_AUDIO_PATH_MASK 0x20
#define EP92_GC_CEC_MUTE_SHIFT 1
#define EP92_GC_CEC_MUTE_MASK 0x02
#define EP92_GC_ARC_EN_SHIFT 0
#define EP92_GC_ARC_EN_MASK 0x01
#define EP92_GC_RX_SEL_SHIFT 0
#define EP92_GC_RX_SEL_MASK 0x07
#define EP92_GC_CEC_VOLUME_SHIFT 0
#define EP92_GC_CEC_VOLUME_MASK 0xff
#define EP92_AI_MCLK_ON_SHIFT 6
#define EP92_AI_MCLK_ON_MASK 0x40
#define EP92_AI_AVMUTE_SHIFT 5
#define EP92_AI_AVMUTE_MASK 0x20
#define EP92_AI_LAYOUT_SHIFT 0
#define EP92_AI_LAYOUT_MASK 0x01
#define EP92_AI_HBR_ADO_SHIFT 5
#define EP92_AI_HBR_ADO_MASK 0x20
#define EP92_AI_STD_ADO_SHIFT 3
#define EP92_AI_STD_ADO_MASK 0x08
#define EP92_AI_RATE_MASK 0x07
#define EP92_AI_NPCM_MASK 0x02
#define EP92_AI_CH_COUNT_MASK 0x07
#define EP92_AI_CH_ALLOC_MASK 0xff
#define EP92_2CHOICE_MASK 1
#define EP92_GC_CEC_VOLUME_MIN 0
#define EP92_GC_CEC_VOLUME_MAX 100
#define EP92_AI_RATE_MIN 0
#define EP92_AI_RATE_MAX 768000
#define EP92_AI_CH_COUNT_MIN 0
#define EP92_AI_CH_COUNT_MAX 8
#define EP92_AI_CH_ALLOC_MIN 0
#define EP92_AI_CH_ALLOC_MAX 0xff
#define EP92_STATUS_NO_SIGNAL 0
#define EP92_STATUS_AUDIO_ACTIVE 1
/* kcontrol storage indices */
enum {
EP92_KCTL_POWER = 0,
EP92_KCTL_AUDIO_PATH,
EP92_KCTL_CEC_MUTE,
EP92_KCTL_ARC_EN,
EP92_KCTL_RX_SEL,
EP92_KCTL_CEC_VOLUME,
EP92_KCTL_STATE,
EP92_KCTL_AVMUTE,
EP92_KCTL_LAYOUT,
EP92_KCTL_MODE,
EP92_KCTL_RATE,
EP92_KCTL_CH_COUNT,
EP92_KCTL_CH_ALLOC,
EP92_KCTL_MAX
};
#endif /* __EP92_H__ */